+3  A: 

Does a replacement happen at all, i.e. do you get the same weird characters when you print $input beforehand? If so, the character sets of your PHP source code file and the input do not match and you might need to use iconv() on the input before replacing.

edit: I took both of your files, uploaded them to my webserver and printing and cleaning works fine (see http://www.tag-am-meer.com/test1/). This is on PHP 4.4.9 and Firefox 3.0.6. More potential problems that come to my mind:

  • Does it work for you on Firefox? I remember vaguely that IE6 (and probably later versions as well) expect the charset in the HTML head section to be written in lowercase ("utf-8")
  • Does your editor include byte order marks (BOM) in the code files? Mine does not, maybe PHP chokes on those.
  • Can you look at the HTTP headers to see if there's something unusual going on, like a bad MIME type? The Tamper Data add-on for Firefox can help with this.
Simon
Yes, blank spaces get replaced, as well as other characters which I haven't included, such as '.'All my files are in utf-8, and if I print ááàà I see it correctly, that's why I think this is weird...
ign
+3  A: 

You may want to try iconv.

David Segonds
+1  A: 

Use

iconv('UTF-8', 'ASCII//TRANSLIT', $input);
vartec
+2  A: 

I have tested your code, and error is in strtolower function...

Replace it with mb_strtolower, like bellow

<!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
    function strClean($input) {
     $input = mb_strtolower($input, 'UTF-8');
     $b = array("á","é","í","ó","ú", "n", " ");
     $c = array("a","e","i","o","u","n", "-");
     return str_replace($b, $c, $input);
    }

    $string = 'á é í ó ú n abcdef ghij';
    echo $string ."<br />". strClean($string);
?>

</body>
</html>
glavić
A: 

Thanks for your help. I'll assume, because of glavić's comments and some suspicion of mine that it is this machine's fault. I'll try at home.

ign