Reputation: 5
I have been trying to analyze it for like hours now but I can't understand what was wrong with my code :(
$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.
}
The variable $d is always 1 inside the other loop but it increments outside the loop. Note there is a while statement inside the while. Is there anything wrong?
I'm using $d
for my array:
$finaloutput = $finaloutput.$database_returned_data[$d][$c].",";
I am a noob poster. Feel free to ask for more details :)
Upvotes: 0
Views: 507
Reputation: 18833
You don't set $a
here:
while($d<$arraycount-2){
while ($a < 40){
So on every iteration besides the first this while condition won't run.
just change it to:
while($d<$arraycount-2){
$a = 0;
while ($a < 40){
Upvotes: 1