Tags: uri,url rewriting

Sort by: Date / Title /

  1. 11 months ago by mikaweb and saved by 1 other
    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. }
  2. 1 year ago by xillon and saved by 5 others
    1. function convert_for_uri($text) {
    2.   // Définition du séparateur
    3.   define("SEPARATOR", "-");
    4.  
    5.   $tofind = "àáâãäåòóôõöøèéêëçìíîïùúûüÿñ"; // Lettre accentuées
    6.   $replac = "aaaaaaooooooeeeeciiiiuuuuyn"; // Equivalant non accentué
    7.  
    8.   // Mise en minuscule + suppression des lettres accentuées par leur équivalant non accentué
    9.   $text = strtr(strtolower($text),$tofind,$replac);
    10.  
    11.   // Remplacement de caractère non alphanumérique par un séparateur
    12.   $text = ereg_replace("[^a-z0-9]", SEPARATOR, $text);
    13.  
    14.   // Suppression des doubles séparateurs
    15.   while (strstr($text, SEPARATOR . SEPARATOR))
    16.     $text = str_replace(SEPARATOR . SEPARATOR, SEPARATOR, $text);
    17.  
    18.   // Retour avec suppression d’un possible séparateur en fin de chaîne
    19.   return(ereg_replace(SEPARATOR . "$", "", $text));
    20. }

First / Previous / Next / Last / Page 1 of 1 (2 posteets)