Return to Snippet

Revision: 5976
at April 18, 2008 06:27 by ibomb


Initial Code
$string = "1@-This is a Random string£";

//not allowed chars
$pattern = '/[^\w\s]+/';
$replacement = '';
$url = preg_replace($pattern, $replacement, $string);

//change the space with -	
$not_allowed = array(" "); 
$url = strtolower(str_replace($not_allowed, "-", $url));

// result
$url = "1-this-is-a-random-string"

Initial URL
http://www.dluxagency.com

Initial Description

                                

Initial Title
String to valid url generator

Initial Tags

                                

Initial Language
PHP