如何将一个大数组切成小数组


how to slice a big array into smaller ones

如何将任意长度的句子分割成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);