note 111694 added to function.str-replace
| From: | DanielLoureiro | Date: | Sun, 17 Mar 2013 20:52:16 +0000 |
| Subject: | note 111694 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194104@lists.php.net to get a copy of this message | ||
if you need to remove accents of string (ex. if you are a portuguese speaker), you can use this:
<?php
function remove_accents($str)
{
$from = array(
"á", "à ", "â", "ã", "ä",
"é", "è", "ê", "ë", "Ã",
"ì", "î", "ï",
"ó", "ò", "ô", "õ", "ö",
"ú", "ù", "û", "ü", "ç",
"Ã", "Ã", "Ã",
"Ã", "Ã", "Ã", "Ã", "Ã",
"Ã", "Ã", "Ã", "Ã", "Ã",
"Ã", "Ã", "Ã",
"Ã", "Ã", "Ã", "Ã", "Ã",
"Ã", "Ã"
);
$to = array(
"a", "a", "a", "a", "a", "e",
"e", "e", "e", "i", "i", "i",
"i",
"o", "o", "o", "o", "o", "u",
"u", "u", "u", "c", "A", "A",
"A",
"A", "A", "E", "E", "E", "E",
"I", "I", "I", "I", "O", "O",
"O",
"O", "O", "U", "U", "U", "U",
"C"
);
return str_replace($from, $to, $str);
}
echo remove_accents("Açaà não é maçã");
?>
----
Server IP: 69.147.83.199
Probable Submitter: 189.27.147.21
----
Manual Page -- http://php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/111694
Del: integrated -- https://master.php.net/note/delete/111694/integrated
Del: useless -- https://master.php.net/note/delete/111694/useless
Del: bad code -- https://master.php.net/note/delete/111694/bad+code
Del: spam -- https://master.php.net/note/delete/111694/spam
Del: non-english -- https://master.php.net/note/delete/111694/non-english
Del: in docs -- https://master.php.net/note/delete/111694/in+docs
Del: other reasons-- https://master.php.net/note/delete/111694
Reject -- https://master.php.net/note/reject/111694
Search -- https://master.php.net/manage/user-notes.php