I am trying to iterate through a string that contains french characters. I have an array of specific french characters that I am looking for that I want to match.
Example:
header("Content-Type: text/html;charset=utf-8");
$string = "HÂPPY Ç" ;
echo $string;//displays correctly
echo "<br>";
$frenchArray = Array('Â','Ç');
for($i=0;$i<mb_strlen($string);$i++)
{
$t = utf8_encode(mb_substr($string,$i,1));
echo "Checking:" . $t . "<br>";
for($x=0;$x<count( $frenchArray);$x++)
{
if($t==$frenchArray[$x])
{
echo "Matched: " . $t . " to " . $frenchArray[$x]."<br>";
}
}
}
Which gives me no matches:
Checking:H
Checking:Ã
Checking:
Checking:P
Checking:P
Checking:Y
Checking:
Checking:Ã
Checking:
I notice that the characters are not displayed correctly in the "Checking:"
Seems like there is something simple that I'm missing here, any help is appreciated!