编程爱好者之家

PHP将数组平分为N份

2018-07-08 282

怎么将数组评分为多个数组呢,这就要用到PHP自带函数array_chunk(),实例如下

$arr=array("value1","value2","value3","value4","value5","value6");
print_r(array_chunk($arr,2));

//结果如下
Array
(
    [0] => Array
        (
            [0] => value1
            [1] => value2
        )

    [1] => Array
        (
            [0] => value3
            [1] => value4
        )

    [2] => Array
        (
            [0] => value5
            [1] => value6
        )

)


同类文章

您的赞赏是对小编最大的支持!