Convert phrase into SEO friendly version


/ Published in: PHP
Save to your folder(s)

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".


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

URL: http://abel-perez.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.