Php character encoding problem

Sorry I’m kind of new to this site so I’m not exactly sure how this works. I have a php character encoding problem. Basically my program needs to take in characters, some of which are special characters and display their values. Here is a simplified version of the part which doesn’t work:

$string = “français”;
for ($i = 0; $i < strlen($string); $i++)
{
echo ord($string[$i]) . " ";
}

The problem comes about when it tries to echo ord($string[$i]) when i equals 4 at which point it must echo ord(ç) which doesn’t work for some reason. What could I do instead so that it gives me the right value for ç and other special characters?

Using the code you posted…


$string = "français";
for ($i = 0; $i < strlen($string); $i++)
{
echo ord($string[$i]) . " ";
}

my results are…


102 114 97 110 195 167 97 105 115

I assume that these are the results you are after.

I’m using “EASYPHP” running PHP version 5.4.4 / Apache 2.4.2.
(they have newer versions, but I’m happy with this one for home use.)