I am trying to make a function that will make a string more web-friendly. I want the result to be suitable for a URL, so no spaces or special characters are allowed, ie "Richard's Website" will become "richards_website".
I finished all the steps except the last one because i am not familiar with regular expressions. The function below is what I have so far, with the missing step. Can someone show me how to write a regular expression that will delete all non-alphanumerics?
function makefriendlyname ($text) {
//returns a web-friendly version of any string passed
$text=str_replace(" ","_",$text); //replace spaces
//now make lower case...
$text = strtolower($text);
//now delete all punctuation (anything that is not a number or lower case letter)...
return $text;
}