Posted By

abelperez on 04/09/11


php seo

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Convert phrase into SEO friendly version

 / Published in: PHP


Useful function for taking the title of an Article or keyword phrase and converting it into an SEO friendly version that can be used in a URL. For example, the title "German Cars are amazing" would be transformed into "german-cars-are-amazing".

  1. function getSeoVersion($phrase) {
  2. return preg_replace('/[^a-z0-9_-]/i', '', strtolower(str_replace(' ', '-', trim($phrase))));
  3. }
  5. // example usage:
  6. echo getSeoVersion("German cars are amazing.");

Report this snippet  

You need to login to post a comment.