This works great. Thanks. Jochem Maas wrote: > > delsvr wrote: >> Just a simple question (with a simple answer, hopefully): how can I >> access >> character x of a utf-8 encoded string? i.e. how would I get this to work: >> >> for($x=0; $x < strlen($utf8); $x++) >> echo "character {$x}:" . $utf8{$x}; >> >> Keep in mind that I have strlen overloaded by mbstring, and this is >> necessary for my purposes because I need to do work on each character. >> Also, >> by "character" I mean, for example: "我". > > substr() should do it. > I don't think you can loop through a multibyte string in the way you want. > > $l = strlen($utf8); > for($x=0; $x < $l; $x++) echo "char {$x}:".substr($utf8, $x, 1); > > > check here to figure out exactly which functions you > are currently overloading: > > http://php.net/mb_string > >> >> Thanks, >> delsvr > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- View this message in context: http://www.nabble.com/PHP%2C-mbstring%2C-UTF-8-and-indexing-strings-tf3972397.html#a11280535 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php