By Alvin Alexander. Last updated: June 6, 2016
A PHP function that strips a string of all characters other than alphanumeric characters:
function onlyAlphanumericAndSpaces($text) {
# allow only alphanumeric
return ereg_replace("[^A-Za-z0-9 ]", "", $text );
}

