-1
如何将$str
拆分为任何拉丁字母为分隔符的部分?php:将字符串拆分为数组作为分隔符
$str = " Hello! How are you? How are you doing? ";
应返回
$arr = (" ", "! ", " ", " ", "? ", " ", " ", " ", "? ");
如何将$str
拆分为任何拉丁字母为分隔符的部分?php:将字符串拆分为数组作为分隔符
$str = " Hello! How are you? How are you doing? ";
应返回
$arr = (" ", "! ", " ", " ", "? ", " ", " ", " ", "? ");
阵列使用正则表达式。在1个或更多字符+
或a-z
分裂A-Z
:
$arr = preg_split('/[a-zA-Z]+/', $str);
在字符类添加任何你想要的0-9
的数字或'
的撇号等这样[]
...