EDIT: This code now works correctly, I only left it in case someone finds themselves in my situation. Thanks.
I’m facing a very strange situation with my code. I have the following:
$m = 0; $star = ""; $star2 = "";
while($star == "")
{
//some stuff
if(m1 == 0) { break; }
$m1 -= 1;
}
For some crazy reason, when I’m debugging this code it runs the while loop only once (even though $star is still equal to "" and then reaches the if and breaks.
I have tried different approaches to no avail. Does anyone know why this is happening?
There’s no $ before m1, so PHP will assume it’s a literal string ‘m1’ and throw a notice error. ‘m1’ is then compared with 0, which is true, and your loop breaks.
You haven’t initialized $m1 in your example either, so even if you used $m1, it would still break.
Make sure you have all PHP errors and warnings turned on, they are very helpful for things like this!