php - Access character in a string with square braces doesn't output correctly -
i have string , want access ä
character. outputs question mark instead of correct character.
here code.
$array = array('ä', 'b', 'c'); $string = 'äbc'; echo $string; // äbc echo '<br />'; echo $string[0]; // ? echo '<br />'; echo $array[0]; // ä
can tell me why?
updated
echo strlen($string); // returns 4 echo mb_substr($string, 0, 1); // ä
depending on charset, letter ä multi-byte letter. when access string using array access, returns first byte. in case of multi-byte ä returns non printable control character.
accessing array using array-access returns first element, regardless of it's length, in case multi-byte ä.
Comments
Post a Comment