Home >Backend Development >PHP Tutorial >PHP uses array_fill to define multi-dimensional arrays_PHP tutorial

PHP uses array_fill to define multi-dimensional arrays_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:02:391050browse

How PHP uses array_fill to define multi-dimensional arrays

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:

?

1

$creation=array_fill(0,3,array_fill(0,2,null));

1
$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

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 )

)

4 5

6

7

$abc=0;

for($j=0;$j<2;$j ) { $abc=$abc 1; $creation[$i][$j]=$abc; } }

The result is: <๐ŸŽœ> <๐ŸŽœ> <๐ŸŽœ> <๐ŸŽœ> <๐ŸŽœ>?<๐ŸŽœ> 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...
Statement๏ผš
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
<๐ŸŽœ>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 ) )