PHP数组循环有关问题

WBOY
Release: 2016-06-13 12:01:22
Original
795 people have browsed it

PHP数组循环问题
$a是数组

while(){    //循环后,$a的值显示出来了
$a=1,2,3,4,5,6,7,8,9,10
}

$a=10   //跳出循环后,$=10

现在我想怎么在while循环外,可以依旧得到这10个数?

我在循环外写
$b=array();
for ($b=0;$a$b=$a;}
这样子$b还是只等于10.

不晓得表述的清不清楚,请大神解答,谢谢!
------解决方案--------------------
$b = array();
for ($i=0; $i  $b[] = $i;
}
print_r($b);
------解决方案--------------------
$b=array();
for ($a=0;$a    array_push($b, $a);
}
print_r($b);
------解决方案--------------------
同意1楼

引用:
$b = array();
for ($i=0; $i  $b[] = $i;
}
print_r($b);

------解决方案--------------------
引用:
Quote: 引用:

$b = array();
for ($i=0; $i  $b[] = $i;
}
print_r($b);


这样输出还是10呀


输出是这个:Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) 
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