How can I use PHP to strip out all characters that are NOT alpha, numeric, space, or puncutation?
I\'ve tried the following, but it strip punctuation.
$str = trim($str); $str = trim($str, "\x00..\x1F"); $str = str_replace(array( ""","'","&","<",">"),' ',$str); $str = preg_replace('/[^0-9a-zA-Z-]/', ' ', $str); $str = preg_replace('/\s\s+/', ' ', $str); $str = trim($str); $str = preg_replace('/[ ]/', '-', $str);
Hope this helps.