Braces.

May 16, 2006 13:19

Apparently, the array subscript operator ( '[]', ie-braces ) produces unexpected results when used on a string containing multibyte data.

eg, if you have:
$s = "foo";
then, $s[0] will be "f".

However, if you have, say:
$s = "こにちわ";

then $s[0] is.. well, what? It's the first byte of $s. But in this case, it's not the first character. ( こ taking up two bytes, obviously )

web, coding, geekery

Previous post Next post
Up