PHP Convert String SEO Friendly

Posted Under: PHP, Programming, SEO, Tutorials on May 25, 2012
This tutorial explains how to create SEO friendly URL using PHP. Friendly URLs improves your site's search engines ranking. To make a SEO friendly URL a string must be sanitized for certain things like...

  • URL should be in lower case
  • All spaces should be replaced with a dash or hyphen (-)
  • URL must only contains letters and numbers.
  • NO HTML is allowed.

I found a very quick and clean way to do this.
function Make_SEO_Friendly_URL($string)
  // replace all non letters or digits with -
  $string = preg_replace('/W+/', '-', $string);

  // trim and lowercase
  $string = strtolower(trim($string, '-'));
  return $string;


$string="making String SEO Friendly with PHP is easy, isnt?";

echo Make_SEO_Friendly_URL($string);

© Tutorial Jinni