PHP Remove Anything that is NOT a Letter
PHP Function to Remove Anything that is NOT a Letter, Meaning Remove Any Numbers, Special Characters etc
Home
Short:
function clean_nonletters($input, $ballow_space = false){ $bfound = false; $spc = ''; // IF SPACES ARE OK SAVE SPACE CHR TO $spc if($ballow_space){ $spc = ' '; } // IF ANYTHING OTHER THAN LETTERS FOUND, REMOVE if (!preg_match('#^[a-z' . $spc . ']+$#', $input)) { $bfound = true; $input = preg_replace('/[^a-z' . $spc . ']/i', '', $input); } return [$bfound, $input]; }
source code home