Create clean URLS (Slugs)
<?php
function slugify ($str, $replace="-") {
// replace all non letters or digits by $replace
$str = preg_replace('/\W+/', $replace, $str);
// trim and lowercase
$str = strtolower(trim($str, $replace));
return $str;
}
?>
Written by Liam Chapman
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Related Tags
#php
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#