PHP strip non alphanumeric

On EveryDayFiction.com, in the titles of the posts our editors insisted on including a non alphanumeric character.
The little dot that separates the title from the author. This causes havoc with a lot of my scripts and is really freaking annoying.

This handy little function strips all the nonĀ  alphanumeric character from the string.

function strip_non_alnum($str) {
$str = preg_replace(‘~^(\s*)(.*?)(\s*)$~m’, “\\2″, $str);
$str = ereg_replace(“[^[:alnum:] ]”,”",$str);
return $str ;
}

No Comments.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>