[php函数]–数组函数–array

array_chunk

版本:>= 4.2说明: array_chunk(array $input, int $size, [, bool $preserve_keys=false])
此函数的作用是将数组分块,当我们对数组里的数据做分批处理时可以使用此函数。参数 input
要处理的数组。size
数组块的大小preserve_keys
是否保留原来的数据的key,默认为不保留。例子$input=array(“a”=>”php”,”b”=>”c”,”c”=>”c++”,”d”=>”python”,”e”=>”ruby”);
$output = array_chunk($input, 2);
#output=>array
(
[0] => array
(
[0] => php
[1] => c
)
[1] => array
(
[0] => c++
[1] => python
)
[2] => array
(
[0] => ruby
)
)
$output2 = array_chunk($input, 2, true);
#output2=> array
(
[0] => array
(
[a] => php
[b] => c
)
[1] => array
(
[c] => c++
[d] => python
)
[2] => array
(
[e] => ruby
)
)
#注意子数组中的key还是保留原来数组中的key

‘).addclass(‘pre-numbering’).hide();
$(this).addclass(‘has-numbering’).parent().append($numbering);
for (i = 1; i

Posted in 未分类

发表评论