Create a slug URL from string of text

Submitted by:Jhon Brain

Date added:28 April, 2012

Category:PHP

Passing in a simple string of text converting it to lowercase and replacing all the spaces with a dash

Tags: create slug , text converting

Code Snippet:

function create_slug(strtolower($string)){
$slug=preg_replace('/[^a-z0-9-]+/', '-', $string);
return $slug;
}

echo create_slug('Create a slug URL from string of text');
 
 

Comments