PHP uses Array_fill to define multidimensional array methods
This article mainly introduces the method that PHP uses Array_fill to define multidimensional array, the example analyzes the use skill of array_fill function in PHP, has certain reference value, need friend can refer to the next
This example describes how PHP uses Array_fill to define multidimensional arrays. Share to everyone for your reference. The specific analysis is as follows:
Multiple Array_fill can be nested in PHP to complete the definition of a multidimensional array:
?
1 |
$creation =array_fill (0,3,array_fill (0,2,null)); |
The following statements can be used to populate:
?
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; } } |
The result is:
?
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 is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/969965.html www.bkjia.com true http://www.bkjia.com/PHPjc/969965.html techarticle PHP uses Array_fill to define multidimensional arrays this article mainly introduces the method of using Array_fill to define the multidimensional array, the example analyzes the use of Array_fill function in PHP, with a ...