Return to Snippet

Revision: 35092
at November 2, 2010 09:33 by liamchapman


Initial Code
<?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;
}

?>

Initial URL


Initial Description
Quick and simple script to make clean urls. Works in combination with Apache mod_rewrites :-)

Initial Title
Slugify function (Clean URLS)

Initial Tags
php

Initial Language
PHP