This article mainly introduces how PHP uses array_fill to define multi-dimensional arrays. It analyzes the usage skills of array_fill function in PHP with examples. Be sure to refer to the reference value. Friends who need it can refer to it
The example in this article describes how PHP uses array_fill to define multi-dimensional arrays. Share it with everyone for your reference. The specific analysis is as follows:
You can use multiple array_fill nestings to complete the definition of multi-dimensional arrays in PHP:
?
|
$creation=array_fill(0,3,array_fill(0,2,null));
|
can be filled with the following statements:
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; } } |
1
2 3
6 7
|
$abc=0; |
<🎜>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 be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/969965.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969965.htmlTechArticleHow PHP uses array_fill to define multi-dimensional arrays. This article mainly introduces how PHP uses array_fill to define multi-dimensional arrays, with examples. Analyzed the usage skills of array_fill function in php, with a...