Function to return only alpha-numeric characters from string ?
Use below code to remove everything except a-z, A-Z and 0-9:
$result = preg_replace("/[^a-zA-Z0-9]+/", "", $s);
Alphanumeric includes letters in foreign languages and obsolete scripts and use the Unicode character classes.
use this to leave only A-Z:
$result = preg_replace("/[^A-Z]+/", "", $s);
The words like résumé contains the letter é that not be matched by this.To match a specific list of letters adjust the regular expression to include those letters. To match all letters, use the appropriate character classes.