Generation of SEO URL in php code

in PHP Code, SEO / 3 Comments

Hi friends below two lines of code is for the generation of user friendly and seo (search engine optimization) urls.

It removes the all white spaces in the url and replace it with the ‘-‘.

It removes the all white spaces at the end of the urls.

It removes the unambiguous text in the urls.

The lines are :

////////////////////////////

*******************************************

$seo_url=trim(ereg_replace(‘ +’,’ ‘,preg_replace(‘/[^a-zA-Z0-9\s]/’,”,strtolower($seo_url))));

$seo_url=str_replace(‘ ‘,’-‘,$seo_url);

********************************************

//////////////////////

Hope that it will working fine …

With more than 8 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

Discussion 3 Comments

  1. Anil Kumar Panigrahi

    It is just replace the spaces in the keywords and replace the single quote with ‘-‘, that is for eg:

    generation of seo url in php code

    if it is topic like this.
    Then it is convert with the above code to

    generation-of-seo-url-in-php-code

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>