Home > Backend Development > PHP Tutorial > PHP uses array_fill to define a multidimensional array method, array_fill multidimensional_PHP tutorial

PHP uses array_fill to define a multidimensional array method, array_fill multidimensional_PHP tutorial

WBOY
Release: 2016-07-13 10:03:00
Original
1059 people have browsed it

PHP uses array_fill to define multi-dimensional arrays, array_fill multi-dimensional

This article describes the example of PHP using 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));
Copy after login

can be filled with the following statements:

$abc=0;
for($i=0;$i<3;$i++) {
 for($j=0;$j<2;$j++) {
 $abc=$abc+1;
 $creation[$i][$j]=$abc;
 }
}
Copy after login

The result is:

Array
(
 [0] => Array ( [0] => 1 [1] => 2 )
 [1] => Array ( [0] => 3 [1] => 4 )
 [2] => Array ( [0] => 5 [1] => 6 )
)
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969481.htmlTechArticlePHP uses array_fill to define multi-dimensional arrays, array_fill multi-dimensional This article describes the example of PHP using array_fill to define multi-dimensional arrays. Share it with everyone for your reference. Specific analysis is as follows...
Related labels:
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