Home > php教程 > php手册 > PHP使用array_fill定义多维数组的方法,array_fill多维

PHP使用array_fill定义多维数组的方法,array_fill多维

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 09:11:28
Original
1231 people have browsed it

PHP使用array_fill定义多维数组的方法,array_fill多维

本文实例讲述了PHP使用array_fill定义多维数组的方法。分享给大家供大家参考。具体分析如下:

PHP中可以用多个array_fill嵌套完成多维数组的定义:

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

可用如下语句进行填充:

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

结果为:

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

希望本文所述对大家的php程序设计有所帮助。

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template