I found a simple function to remove some unwanted characters from a string.
function strClean($input){ $input = strtolower($input); $b = array("á","é","í","ó","ú", "ñ", " "); //etc... $c = array("a","e","i","o","u","n", "-"); //etc... $input = str_replace($b, $c, $input); return $input; }
When I use it for accents or other characters, like the word "á é ñ", it prints these question marks or strange characters, for example: output http://img217.imageshack.us/img217/6794/59472278.jpg
Note. I use strclean.php (which contains this function) and index.php, as in UTF-8. index.php is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <?php include('strclean.php'); echo 'óóóáà'; echo strClean('óóóáà'); ?> </body> </html>
What am I doing wrong?
string php unicode utf-8
Nacho Mar 03 '09 at 14:40 2009-03-03 14:40
source share