NYCPHP Meetup

[nycphp-talk] iterating through a multibyte string

Dan Cech dcech at phpwerx.net
Wed Jan 13 10:23:56 EST 2010


Rob,

> I have a need to iterate through a multibyte string to process the string character by character.

> -- Is using mb_substr($str, $i, 1) the only way to get this to work in php5?  That's my question.
> 
> It seems like it's going to be many times slower according to some of the comments I've seen on the multibyte functions in the php manual.

This might be a bit quicker:

$str = "string with utf-8 chars åèö";
$t = preg_split('//u',$str,-1,PREG_SPLIT_NO_EMPTY);
var_dump($t);

Dan



More information about the talk mailing list