Help with replacing characters
<p>Hopefully someone can help out here;</p>

<p>I am trying to write a function which replaces special characters and returns the correct one.</p>

<p>This is what I have so far:</p>

<pre><code>function convertlatin($output){ 

    $latinchar = array("â‚¬", "â€š","Æ'","â€ž","â€¦","â€¡","Ë†","â€°","Å","â€¹","Å'",'Å½','â€˜','â€™','â€œ','â€','â€¢','â€"','â€"','Ëœ','â"¢','Å¡','â€º','Å"',"Å¾",'Å¸','Â¡','Â¢','Â£','Â¤','Â¥','Â¦','Â§','Â¨','Â©','Âª','Â«','Â¬','Â®','Â¯','Â°','Â±','Â²','Â³','Â´','Âµ','Â¶','Â·','Â¸','Â¹','Âº','Â»','Â¼',"Â½",'Â¾','Â¿','Ã€','Ã','Ã‚','Ãƒ','Ã"','Ã…','Ã†','Ã‡','Ãˆ','Ã‰','ÃŠ','Ã‹','ÃŒ    ','Ã','ÃŽ','ÃŸ','Ã',"Ã'","Ã'",'Ã"','Ã"','Ã•','Ã–','Ã—','Ã˜','Ã™','Ãš','Ã›','Ãœ','Ã','Ãž','ÃŸ','Ã','Ã¡','Ã¢','Ã£','Ã¤','Ã¥','Ã¦','Ã§','Ã¨','Ã©','Ãª','Ã«','Ã¬','Ã','Ã®','Ã¯','Ã°','Ã±','Ã²','Ã³','Ã´','Ãµ','Ã¶','Ã·','Ã¸','Ã¹','Ãº','Ã»','Ã¼','Ã½',"Ã¾","Ã¿");
    $correctchar = array("€", "‚","ƒ",'"','…','‡','ˆ','‰',"Š",'‹','Œ','Ž',"'","'",'"','"','•','–','—','˜','™','š','›','œ','ž','Ÿ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ',"ÿ");

    $returnval = str_replace($latinchar, $correctchar, $output);

    echo($returnval);
    return $returnval;
}
</code></pre>

<p>The problem I have is I thought it was working but it has random results, such as if it finds a match on just one of the characters it replaces a different one in that array. What I would like to do is find and replace an exact match of latin char within a supplied string eg "testingÃ¿" with "testingÿ" - at the mo it replaces Ã¿ with testingá¿</p>

<p>It just seems to replace one character in some occasions, when I would like it to match and replace both parameters.</p>

<p>I also tried strcmp with not much success.</p>

<p>Any ideas ?</p>
