array_chunk() 把一个数组分割成新的数组块
array array_chunk(array $array,int $size[,bool preserve_key])
参数描述:array是分割的数组
size规定每个新数组包含的元素,最后一个数组可能会少几个元素
preserve_key:可选,有两个选项:true,保留原始数组中的键名;false,默认选项,每个结果数组使用从0开始的新数组索引
示例:
$array = array(
'a'=>'JAVA',
'b'=>'PHP',
'c'=>"C++",
'd'=>'c#',
'e'=>'perl'
);
print_r(array_chunk($array,2,false));
echo PHP_EOL;
print_r(array_chunk($array,2,true));
运行结果如下:
Array ( [0] => Array ( [0] => JAVA [1] => PHP ) [1] => Array ( [0] => C++ [1] => c# ) [2] => Array ( [0] => perl ) )
Array ( [0] => Array ( [a] => JAVA [b] => PHP ) [1] => Array ( [c] => C++ [d] => c# ) [2] => Array ( [e] => perl ) )
本文由 HongXunPan 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:
2018-08-24 18:03:35
cheers lots this fabulous website is actually conventional in addition to casual
http://hd-kinolar.net wiki.fairspark.com balance of nature balance of nature https://minhtanstore.com
I'm not sure where you're getting your information, but great topic. I needs to spend some time learning much more or understanding more. Thanks for great info I was looking for this info for my mission.
Are you currently looking for escort girls in Tel Aviv ?18escortgirls can cause you to Want to pay quality young escort girls in your house or hotel? Searching for Russian escorts, Ethiopian escorts or VIP escorts? Looking for escort services in Tel Aviv with the truly amazing way to obtain 18escortgirls Index can fulfill all your fantasies discreetly.
Hi to every one, the contents present at this web site are in fact remarkable for people knowledge, well, keep up the good work fellows.
hydroxychloroquine pills does hydroxychloroquine cause hair loss hydroxychloroquine pills