Monday 24 September 2018

SEO Friendly Links in PHP

This code removes all special characters from the given URL and make it SEO friendly.

<?php       
function makeMyUrlFriendly($url){
    $output = preg_replace("/\s+/" , "_" , trim($url));
    $output = preg_replace("/\W+/" , "" , $output);
    $output = preg_replace("/_/" , "-" , $output);
    return strtolower($output);
}
?>

Previous Post
Next Post

post written by:

0 Comments:

Hit me with a comment!