变量不会改变其值

时间:2013-09-24 16:42:48

标签: php

我一直试图分析它几个小时,但我无法理解我的代码有什么问题:(

$d = 1; //I declare this variable as 1
$a = 0;
while($d<$arraycount-2){
  while ($a < 40){
    $c = 0;
    $b = 0;

    while($c < $fc){
      $finaloutput = $finaloutput.$database_returned_data[$d][$c].","; //But here, in this loop $d is always 1

      $c++;
    }

    while($b < 5){
      $finaloutput = $finaloutput.$mydata[$a][$b].",";
      $b++;
    }

    $finaloutput = $finaloutput."--END--";
    $a++;
  }
  $d++; //But it increments successfully. Hence, the while loop terminates after it meets the criteria.
}

变量$ d在另一个循环中始终为1,但它在循环外递增。注意while里面有一个while语句。有什么不对吗?

我正在使用$d作为我的数组:

 $finaloutput = $finaloutput.$database_returned_data[$d][$c].",";

我是一个菜鸟海报。随意询问更多细节:)

1 个答案:

答案 0 :(得分:1)

您未在此处设置$a

while($d<$arraycount-2){
    while ($a < 40){

因此,除了第一次迭代之外,每次迭代都不会运行。

只需将其更改为:

while($d<$arraycount-2){
    $a = 0;
    while ($a < 40){
相关问题