note 108310 added to function.strtr
| From: | contato at sitepor500 dot com dot br | Date: | Mon, 16 Apr 2012 12:42:12 +0000 |
| Subject: | note 108310 added to function.strtr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187179@lists.php.net to get a copy of this message | ||
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
----
Server IP: 89.185.144.38
Probable Submitter: 189.34.49.81
----
Manual Page -- http://www.php.net/manual/en/function.strtr.php
Edit -- https://master.php.net/note/edit/108310
Del: integrated -- https://master.php.net/note/delete/108310/integrated
Del: useless -- https://master.php.net/note/delete/108310/useless
Del: bad code -- https://master.php.net/note/delete/108310/bad+code
Del: spam -- https://master.php.net/note/delete/108310/spam
Del: non-english -- https://master.php.net/note/delete/108310/non-english
Del: in docs -- https://master.php.net/note/delete/108310/in+docs
Del: other reasons-- https://master.php.net/note/delete/108310
Reject -- https://master.php.net/note/reject/108310
Search -- https://master.php.net/manage/user-notes.php