关于php数组while循环问题!
<?phpfor($i=1;$i<=10;$i++){$num[$i]=$i;print_r($num);echo'<br/>';}输出结果:Array([1]=...
<?php for($i=1;$i<=10;$i++) { $num[$i]=$i; print_r($num); echo '<br />'; } 输出结果: Array ( [1] => 1 ) Array ( [1] => 1 [2] => 2 ) Array ( [1] => 1 [2] => 2 [3] => 3 ) Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 ) Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 ) Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 ) Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 ) Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 ) Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 [10] => 10 ) 问题是: 为何在输出 第二排时,还会出现[1] => 1 呢?同理,第三排的 [3] => 3时,为何还会出现 [1] => 1 [2] => 2等等,为何不是第二排输出array([2] => 2),第三排array([3] => 3)? 这个循环让我很头晕!极盼赐教,谢谢!
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询