I'm looking for a php function that will take an input string and return a sanitized version of it by stripping away all special characters leaving only alpha-numeric.
I need a second function that does the same but only returns alphabetic characters A-Z.
Any help much appreciated.
Rather than preg_replace
, you could always use PHP's filter functions using the filter_var()
function with FILTER_SANITIZE_STRING
.
Source: Stackoverflow.com