PHP uses array_fill to define multi-dimensional arrays
This article describes how to use array_fill to define multi-dimensional arrays in PHP. The example shows how to use the array_fill function in php. It has some reference value. For more information, see
This example describes how PHP uses array_fill to define multi-dimensional arrays. 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:
?
1 |
$ Creation = array_fill (0, 3, array_fill (0, 2, null )); |
You can fill in the following statement:
?
1 2 3 4 5 6 7 |
$ Abc = 0; For ($ I = 0; $ I <3; $ I ++ ){ For ($ j = 0; $ j <2; $ j ++ ){ $ Abc = $ abc + 1; $ Creation [$ I] [$ j] = $ abc; } } |
Result:
?
1 2 3 4 5 6 |
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.