我有一个数组:
Array
(
[0] => Array
(
[u_id] => 2
[u_name] => Test USER
[r_nb_today] => 2
[r_nb_total] => 4
)
[1] => Array
(
[u_id] => 4
[u_name] => Test USER
[r_nb_today] => 0
[r_nb_total] => 0
)
[2] => Array
(
[u_id] => 5
[u_name] => Test USER
[r_nb_today] => 0
[r_nb_total] => 0
)
[3] => Array
(
[u_id] => 6
[u_name] => Test USER
[r_nb_today] => 0
[r_nb_total] => 0
)
)
该数组大于此数组,现在我想以相同的顺序将其保留,并将其拆分为多个数组,每个数组最多限制10个条目(例如SQL中的LIMIT 10)。
该怎么做?
谢谢。
答案 0 :(得分:1)
按照@devpro的注释(在此处写下以得到官方答复):
您可以使用array-chunk将数组分块为具有size元素的数组。最后一块可能包含少于size的元素。
在您的情况下将其用作:
$chuncks = array_chunk($array, $limit));