Return to Snippet

Revision: 62340
at February 17, 2013 20:25 by apphp-snippets


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

Initial URL
http://www.apphp.com/index.php?snippet=php-seo-friendly-links

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

Initial Title
SEO friendly links in PHP

Initial Tags
php, links

Initial Language
PHP