1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| function clean_url_parameter($string){
$search = array('%', '+', '=', '£', '$', '', '"', '&', '<', '>');
$replace = array('-pourcent', '-plus', '-egal', '-livre', '-dollar', '-euro', '', '-et', '-', '-');
$string = str_replace($search, $replace, strip_tags($string));
$search = 'çñÄÂÀÁäâàáËÊÈÉéèëêÏÎÌÍïîìíÖÔÒÓöôòóÜÛÙÚüûùúµ';
$replace = 'cnaaaaaaaeeeeeeeeeiiiiiiiioooooooouuuuuuuuu';
$string = strtr(trim(strtolower($string)), $search, $replace);
$string = preg_replace('/[^a-z0-9-]/', '-', $string);
$string = trim($string, '-');
while(strpos($string, '--') > 0){
$string = str_replace('--', '-', $string);
}
return $string;
} |
Partager