PHP uses array_fill to define multi-dimensional arrays. PHP uses array_fill to define multi-dimensional arrays. This article mainly introduces how PHP uses array_fill to define multi-dimensional arrays. The example shows how to use the array_fill function in php, has a PHP method to define multi-dimensional arrays using array_fill
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.
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...