This article describes how to use array_fill in PHP to define multi-dimensional arrays. The example shows how to use the array_fill function in php, which has some reference value, for more information about how to use array_fill to define multi-dimensional arrays in PHP, see the following example. Share it with you for your reference. The specific analysis is as follows:
In PHP, multiple array_fill nesting can be used to define multi-dimensional arrays:
$ Creation = array_fill (0, 3, array_fill (0, 2, null ));
You can fill in the following statement:
$ Abc = 0; for ($ I = 0; $ I <3; $ I ++) {for ($ j = 0; $ j <2; $ j ++) {$ abc = $ abc + 1; $ creation [$ I] [$ j] = $ abc ;}}
Result:
Array ([0] => Array ([0] => 1 [1] => 2) [1] => Array ([0] => 3 [1] => 4) [2] => Array ([0] => 5 [1] => 6 ))
I hope this article will help you with php programming.