douping5226 2016-11-08 03:01
浏览 105
已采纳

PHP:将多字节字符串拆分为没有空格的字符

How to split this string 'هذا   مثال' into seperate characters without whitespace using preg_split or mb_split?
I'm trying to split with preg_split('//u', $str, NULL, PREG_SPLIT_NO_EMPTY) but not to remove whitespace.

I want the following result: (remove space without using preg_replace or str_replace)

Array
(
    [0] => ه
    [1] => ذ
    [2] => ا
    [3] => م
    [4] => ث
    [5] => ا
    [6] => ل
)
  • 写回答

1条回答 默认 最新

  • dongtaoxue4674 2016-11-08 03:29
    关注
    $chars = preg_split('/[\.\s]?/u', $str, NULL, PREG_SPLIT_NO_EMPTY);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?