-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
的數字或'
的撇號等這樣[]
...