PHP: Split multibyte string (word) into separate characters

Peterim picture Peterim · Mar 31, 2010 · Viewed 12k times · Source

Trying to split this string "主楼怎么走" into separate characters (I need an array) using mb_split with no luck... Any suggestions?

Thank you!

Answer

user187291 picture user187291 · Mar 31, 2010

try a regular expression with 'u' option, for example

  $chars = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY);