Function to clear characters with php
October 5th, 2006
Params:$s: Original text.
Return:The text without the specials chars
-
function clearChars($s)
-
{
-
//Array with the chars to remplace
-
$remplazos = Array
-
(
-
"[áàâãª]" => "a",
-
"[ÁÀÂÃ]" => "A",
-
"[ÍÌÎ]" => "I",
-
"[íìî]" => "i",
-
"[éèê]" => "e",
-
"[ÉÈÊ]" => "E",
-
"[óòôõº]" => "o",
-
"[ÓÒÔÕ]" => "O",
-
"[úùû]" => "u",
-
"[ÚÙÛ]" => "U",
-
"ç" => "c",
-
"Ç" => "C",
-
"[ñ]" => "n",
-
"[Ñ]" => "N"
-
);
-
foreach($remplazos AS $original => $remplazo)
-
$s = ereg_replace($original,$remplazo,$s);
-
return $s;
-
}


Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed