Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 每3个元素创建一个多维数组_Php_Loops_Foreach - Fatal编程技术网

Php 每3个元素创建一个多维数组

Php 每3个元素创建一个多维数组,php,loops,foreach,Php,Loops,Foreach,我有以下数组: Array { [0] => text1 [1] => text2 [3] => text3 [4] => text4 ... [200] => text200 } 如何创建一个foreach循环,将上述数组分割为每3个元素创建一个子数组 Array { [0] => Array { [0] => text1 [1]

我有以下数组:

Array {
    [0] => text1
    [1] => text2
    [3] => text3
    [4] => text4
    ...
    [200] => text200
}
如何创建一个foreach循环,将上述数组分割为每3个元素创建一个子数组

Array {
    [0] => Array {
                [0] => text1
                [1] => text2
                [2] => text3 
    }
    [1] => Array {
                [0] => text4
                [1] => text5
                [2] => text6
    }   
   ......
}
您可以使用内置函数,
array\u chunk()

array_chunk($input_array, 3)