ScriptPlazzaon Google+

This little snippet removes any weird characters and converts everything to lowercase.

function makeUrlFriendly($input)
{
    $output = preg_replace("/\s+/" , "_" , trim($input));
    $output = preg_replace("/\W+/" , "" , $output);
    $output = preg_replace("/_/" , "-" , $output);
    return strtolower($output);
}
 

Leave a Comment

You must be logged in to post a Review.