Strip All Non Alphanumeric Characters Except Space With PHP

Must Read : Strip All Non Alphanumeric Characters Except Space With PHP

A quite common request received by PHPRO is to strip all “bad characters” except for a space. Bad characters are defined in these requests as any non alpha numeric characters. Most often these requests are from people who wish to sanitize postal addresses or the like. This simple function provides a basic wrapper for the PHP function preg_match to strip out the unwanted characters and returns a sanitized string, including white space characters.

(Visited 36 times, 1 visits today)

Leave a Comment.