How to remove the special characters in title?

$hotel=" How to study; PHP? ";
$foldername = stripslashes ($hotel);
//This erase white-spaces on the beginning and the end in each line of a string:
$foldername = preg_replace('~^(\s*)(.*?)(\s*)$~m', "\\2", $foldername);
//erases all NON-alfanumerics
$foldername = ereg_replace("[^[:alnum:] ]","",$foldername);
// take out repetative spaces:
$foldername = preg_replace(’/\s\s+/’, ‘ ‘, $foldername);
if ($foldername == “”){$foldername = “untitled”;}
$foldername= trim(strtolower($foldername));
$array=explode(” “,$foldername);
$foldername=implode(”-”, $array);
echo ($foldername);
?>

Posted in Php Learning.

Leave a Reply

You must be logged in to post a comment.