Slug string maker

<?php

function slugger($n){


$n = preg_replace('/\%/',' percentage',$n); 
$n = preg_replace('/\@/',' at ',$n); 
$n = preg_replace('/\&/',' and ',$n); 
$n = preg_replace('/\s[\s]+/','-',$n);    // Strip off multiple spaces 
$n = preg_replace('/[\s\W]+/','-',$n);    // Strip off spaces and non-alpha-numeric 
$n = preg_replace('/^[\-]+/','',$n); // Strip off the starting hyphens 
$n = preg_replace('/[\-]+$/','',$n); // // Strip off the ending hyphens 
$n = strtolower($n); 

return $n
}

echo slugger("This is the string to be made SEO friendly!")
?>

Comments

comments

Leave a Comment.