Tuesday, June 5, 2018

PHP - remove all except letters, numbers, dashes and blanks

 
PHP - remove all except letters, numbers, dashes and blanks for various cases, like cleaning user input for DB storage, further execution and making it safe.


It's very easy to remove special characters.

$search = preg_replace('/[^a-zA-Z0-9  -]/', '', $search);

No comments:

Post a Comment