I know how to split a text into an array:
我知道如何将文本拆分为数组:
$wordArray = preg_split('#\PL+#u', $text, -1, PREG_SPLIT_NO_EMPTY);
I want to split the text into two-worded parts, so the array doesn't include single words. How to do that?
我想将文本拆分为两个措辞部分,因此数组不包含单个单词。怎么做?
1 个解决方案
#1
0
Try to use
尝试使用
$wordArray = preg_split('#([\w\']+\W+[\w\']+)\W+#u', $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
#1
0
Try to use
尝试使用
$wordArray = preg_split('#([\w\']+\W+[\w\']+)\W+#u', $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);