I was coding PHP when suddenly Im being confused with variable scopes.
If I do the loop like this ...
function foo() { $ctr = 0; for ($i = 0 ; $i > 8 ; $i++) { $ctr = $ctr + 1; } return $ctr; } $ctr returns a 0.
But if I do the loop like this ...
function foo() { $collections = //This has 7 counts; $ctr = 0; foreach ($collections as $collection) { $ctr = $ctr + 1; } return $ctr; } CTR IS RETURNING 7!
So what's is the problem in the first loop?
IF TRUE enter the loop ELSE don't run the loop$i < 8?$iis never higher than 8 in your case, hence the if is getting "skipped". So yes, the problem is in the first loop, and it actually is that the condition you wanted is probably$i < 8instead.