Outputing a non-ASCII character using echo in php

29 Views Asked by At

Consider my following PHP code:

$text="আমাদের";
echo $text[0];

The word আমাদের is a Bengali word. The problem is that, even each of the characters in the string has no ASCII value, the code ord($text[0]) outputs a number. Moreover, the above program outputs a non sense character while it should show the first character in the string $text, that's what the index 0 means. I am showing my output in a HTML page that has UTF-8 encoding set as <meta charset='UTF-8'>. The question is why I am not getting the desired output, which is the first character 'অ', rather, a non-sense character.

0

There are 0 best solutions below