Return to Snippet

Revision: 32756
at October 2, 2010 01:36 by jprochazka


Updated Code
<?php

function seo($string){
  $string = preg_replace("`\[.*\]`U","",$string);
  $string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string);
  $string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string );
  $string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string);
  $string = htmlentities($string, ENT_COMPAT, 'utf-8');return strtolower(trim($string, '-'));
}

?>

Revision: 32755
at October 2, 2010 01:36 by jprochazka


Initial Code
<?php

function seo($string){
  $string = preg_replace("`\[.*\]`U","",$string);
  $string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string);
  $string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string );
  $string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string);
  $string = htmlentities($string, ENT_COMPAT, 'utf-8');return strtolower(trim($string, '-'));
}

?>

Initial URL

                                

Initial Description
The following function will return a SEO friendly URL using a supplied string.

Initial Title
Make a \"SEO Friendly URL\" string.

Initial Tags

                                

Initial Language
PHP