note 85431 added to function.str-replace
| From: | marco dot carvalho at onda dot com dot br | Date: | Fri, 29 Aug 2008 18:54:34 +0000 |
| Subject: | note 85431 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143989@lists.php.net to get a copy of this message | ||
If you need to replace áóÃóú and other special char, you need encondig type suport.
For this, just use htmlentities and some regular expressions
<?PHP
function RemoveAcentos($str, $enc = "UTF-8"){
$acentos = array(
'A' =>
'/À|Á|Â|Ã|Ä|Å/',
'a' =>
'/à|á|â|ã|ä|å/',
'C' => '/Ç/',
'c' => '/ç/',
'E' => '/È|É|Ê|Ë/',
'e' => '/è|é|ê|ë/',
'I' => '/Ì|Í|Î|Ï/',
'i' => '/ì|í|î|ï/',
'N' => '/Ñ/',
'n' => '/ñ/',
'O' => '/Ò|Ó|Ô|Õ|Ö/',
'o' => '/ò|ó|ô|õ|ö/',
'U' => '/Ù|Ú|Û|Ü/',
'u' => '/ù|ú|û|ü/',
'Y' => '/Ý/',
'y' => '/ý|ÿ/',
'a.' => '/ª/',
'o.' => '/º/'
);
return preg_replace($acentos, array_keys($acentos), htmlentities($str,ENT_NOQUOTES, $enc));
}
?>
----
Server IP: 200.185.109.13
Probable Submitter: 189.34.120.241
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/85431
Del: integrated -- https://master.php.net/note/delete/85431/integrated
Del: useless -- https://master.php.net/note/delete/85431/useless
Del: bad code -- https://master.php.net/note/delete/85431/bad+code
Del: spam -- https://master.php.net/note/delete/85431/spam
Del: non-english -- https://master.php.net/note/delete/85431/non-english
Del: in docs -- https://master.php.net/note/delete/85431/in+docs
Del: other reasons-- https://master.php.net/note/delete/85431
Reject -- https://master.php.net/note/reject/85431
Search -- https://master.php.net/manage/user-notes.php