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

WBOY
Release: 2016-07-13 10:02:39
Original
1011 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
<🎜>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 ) )