View

Formater une URL proprement pour URL Rewriting

Note

Il vous suffit ensuite de déclarer ainsi function format_url();

  1. function format_url( $url, $type = ){
  2.         $url = preg_replace(“`\[.*\]`U”,“”,$url);
  3.         $url = preg_replace(‘`&(amp;)?#?[a-z0-9]+;`i’,‘-‘,$url);
  4.         $url = htmlentities($url, ENT_COMPAT);
  5.         $url = preg_replace( “`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i”,\\1″, $url );
  6.         $url = preg_replace( array(“`[^a-z0-9]`i”,“`[-]+`”) , “-“, $url);
  7.         $url = ( $url == “” ) ? $type : strtolower(trim($url, ‘-‘));
  8.         return $url;
  9. }

You may also like