SEO friendly links in PHP

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

     <?php        
/* Source: http://www.apphp.com/index.php?snippet=php-seo-friendly-links */	
    function makeMyUrlFriendly($url){
        $output = preg_replace("/\s+/" , "_" , trim($url));
        $output = preg_replace("/\W+/" , "" , $output);
        $output = preg_replace("/_/" , "-" , $output);
        return strtolower($output);
    }
    ?>

Usage


Comments

Add your comment