开发者

Break an array into different arrays containing x elements each

If I have a single array that has around 5000 elements.

I want 50 arrays out it having 100 elements each. And of course if there are 4923 elements, out of the 50 arrays, there will be 23 in the last one.

I know there must开发者_如何学Go be some built-in function for this. But can't get around one.


It is http://ru2.php.net/array_chunk

$splitted = array_chunk($my_array, 100);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜