Posted By

apphp-snippets on 02/17/13


Tagged

php links seo


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Abiotic
fackz


SEO friendly links in PHP


 / Published in: PHP
 

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

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

  1. <?php
  2. function makeMyUrlFriendly($url){
  3. $output = preg_replace("/\s+/" , "_" , trim($url));
  4. $output = preg_replace("/\W+/" , "" , $output);
  5. $output = preg_replace("/_/" , "-" , $output);
  6. return strtolower($output);
  7. }
  8. ?>

Report this snippet  

You need to login to post a comment.