1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| function CalculateURLFromString($basetxt)
{
$basetxt=unaccent($basetxt);
$basetxt=strtolower($basetxt);
$basetxt=strtr($basetxt, ' ?+!,/\.()"%'."'", '-------------');
while(strpos($basetxt,'--')!==false)
$basetxt=str_replace('--','-',$basetxt);
while(substr($basetxt, -1)=='-')
$basetxt=substr($basetxt, 0, -1);
while(substr($basetxt, 0, 1)=='-')
$basetxt=substr($basetxt, 1);
return $basetxt;
}
function unaccent($string)
{
return strtr( strtr($string,
'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ',
'AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'),
array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss',
'' => 'OE', '' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u',
'&' => 'and'));
} |
Partager