explode() on Japanese string

后端 未结 5 1316
情话喂你
情话喂你 2021-01-21 04:41

I have to use the explode() function on Japanese text but it doesn\'t work.

Here is an example of what I have

$string = \'私 は イタリア 人 です\';
$string = expl         


        
5条回答
  •  北恋
    北恋 (楼主)
    2021-01-21 05:16

    There are a number of characters other than simple ASCII space that can add whitespace between characters.

    You could try using preg_split using \s (whitespace characters) or \b (word boundaries) as the pattern, however this may not be ideal as Japanese is almost certainly going to be encoded in a multiple-byte format.

提交回复
热议问题