Adrien LOCHON
|
Tuesday 01 February 2011 6:05:16 am
Hi, I would have used a ID for that. Instead of using a filter on a name, with spaces, accents and things like that, a ID is much better for accuracy. Or, if you don't want to use any ID or you can't, use a string converter function like this :
function tvReplayImportFiltreBadChars($sContent) {
$sContent = str_replace(" ", " ", $sContent);
$sContent = trim($sContent);
$sContent = str_replace("«", "\"", $sContent);
$sContent = str_replace("»", '"', $sContent);
$sContent = str_replace("“", "\"", $sContent);
$sContent = str_replace("”", "\"", $sContent);
$sContent = str_replace("…", "...", $sContent);
$sContent = str_replace("´", "'", $sContent);
$sContent = str_replace("‘", "'", $sContent);
$sContent = str_replace("’", "'", $sContent);
$sContent = str_replace("œ", "oe", $sContent);
$sContent = str_replace(chr(197).chr(34), "oe", $sContent);
$sContent = str_replace(chr(226) . chr(128) . chr(147), "-", $sContent);
$sContent = str_replace("Œ", "OE", $sContent);
$sContent = str_replace("—", "-", $sContent);
$sContent = str_replace("–", "-", $sContent);
$sContent = str_replace("–", "-", $sContent);
$sContent = str_replace("•", "-", $sContent);
$sContent = str_replace("Ÿ", "Y", $sContent);
$sContent = str_replace("ž", "z", $sContent);
$sContent = str_replace("Ž", "Z", $sContent);
$sContent = str_replace("Š", "S", $sContent);
$sContent = str_replace("š", "s", $sContent);
$sContent = str_replace("›", ">", $sContent);
$sContent = str_replace("‹", "<", $sContent);
$sContent = str_replace("€", "E", $sContent);
$sContent = str_replace(chr(226).chr(130).chr(172) , 'euros', $sContent );
$sContent = str_replace(chr(195).chr(169), "é", $sContent);
$sContent = str_replace(chr(195).chr(34), "û", $sContent);
$sContent = str_replace(chr(195).chr(170), "ê", $sContent);
$sContent = str_replace(chr(195).chr(168), "è", $sContent);
$sContent = str_replace(chr(195).chr(32), "à" . chr(32), $sContent);
$sContent = str_replace(chr(195).chr(162), "â", $sContent);
$sContent = str_replace(chr(195).chr(69), "à", $sContent);
$sContent = str_replace(chr(194).chr(34), '"', $sContent);
$sContent = str_replace(chr(226).chr(69).chr(153), "'", $sContent);
$sContent = str_replace(chr(226).chr(69).chr(166), "...", $sContent);
$sContent = str_replace(chr(195).chr(167), "ç", $sContent);
$sContent = trim($sContent);
$sContent = strtoupper($sContent);
$aLettres = array(",", ";", ".", ":", "°", "-", "_", "'", '"', "&", " ", "/", "\\", "@", "$", "%", "£", "¤", "µ", "*", "!", "§");
$sContent = str_replace($aLettres, " ", $sContent);
$sContent = str_replace(" ", "", $sContent);
$sContent = strtr(utf8_decode($sContent), utf8_decode("ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ"), "aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
$sContent = strtolower($sContent);
$sContent = utf8_encode($sContent);
return $sContent;
} This will change something like "île-de-fortûné" into "iledefortune", avoiding search errors, at least most of them i suppose... I use it a lot to match movies titles between our portal and our partners. My opinion is : use ids :)
|