note 108310 deleted from function.strtr by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 17:10:42 +0000 |
| Subject: | note 108310 deleted from function.strtr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187665@lists.php.net to get a copy of this message | ||
Note Submitter: contato at sitepor500 dot com dot br
----
I use the following code to clean up special characters and convert:
function encodar_termo_busca($termo_busca) {
$caracteres_especiais = array('Å '=>'S',
'Å¡'=>'s',
'Ã'=>'Dj','Ž'=>'Z',
'ž'=>'z', 'Ã'=>'A',
'Ã'=>'A', 'Ã'=>'A',
'Ã'=>'A',
'Ã'=>'A','Ã
'=>'A',
'Ã'=>'A', 'Ã'=>'C',
'Ã'=>'E', 'Ã'=>'E',
'Ã'=>'E', 'Ã'=>'E',
'Ã'=>'I', 'Ã'=>'I',
'Ã'=>'I','Ã'=>'I',
'Ã'=>'N', 'Ã'=>'O',
'Ã'=>'O', 'Ã'=>'O',
'Ã'=>'O', 'Ã'=>'O',
'Ã'=>'O', 'Ã'=>'U',
'Ã'=>'U','Ã'=>'U',
'Ã'=>'U', 'Ã'=>'Y',
'Ã'=>'B',
'Ã'=>'Ss','Ã '=>'a',
'á'=>'a', 'â'=>'a',
'ã'=>'a',
'ä'=>'a','å'=>'a',
'æ'=>'a', 'ç'=>'c',
'è'=>'e', 'é'=>'e',
'ê'=>'e', 'ë'=>'e',
'ì'=>'i', 'Ã'=>'i',
'î'=>'i', 'ï'=>'i',
'ð'=>'o', 'ñ'=>'n',
'ò'=>'o', 'ó'=>'o',
'ô'=>'o', 'õ'=>'o',
'ö'=>'o', 'ø'=>'o',
'ù'=>'u', 'ú'=>'u',
'û'=>'u', 'ý'=>'y',
'ý'=>'y', 'þ'=>'b',
'ÿ'=>'y', 'Æ'=>'f');
$termo_busca = strtolower(strtr($termo_busca,$caracteres_especiais));
$termo_busca = preg_replace("/[^a-z]/i"," ",$termo_busca);
$termo_busca = trim(str_replace(" ","+",$termo_busca),"+");
return $termo_busca . "+site%3Amuraldaufsc.com.br";
}
In my web site www.sitepor500.com.br I pass many parameters in the URL and this is a good and
functional method to make it safely