如何将任意长度的句子切成5个单词的数组?
换一种说法:
$Dummy = "Here is a long sentence, but what I need to make out of this sentence is that it should be chunked off to smaller arrays with 5 words each."
我想用PHP的答案.
在此先感谢解决它的人.
见array_chunk()
.
$words = str_word_count($sentence, 1); $chunks = array_chunk($words, 5);