note 108310 added to function.strtr

From: 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

« previous php.notes (#187179) next »