Reputation: 1320
I have the following code, unfortunately it's looping infinity but I can't understand why :
$tot_age is
set to 604245119
while ($tot_age > 536467742) {
$tot_age - 31536000;
if ($tot_age < 536467742 ) {
// do something
break;
}
}
So what I'm attempting to here is the following. If $tot_age
is greater than 17 years, iterate through the loop and minus 12 months from $tot_age. I'm then attempting to break out of the loop at the point which $tot_age is less than 17 years. I'll apply some logic here too.
Can anyone see an issue here? Thanks
Upvotes: 0
Views: 58
Reputation: 51
Youre not changing the value of tot_age in the loop, you're just making an empty statement. Change:
$tot_age - 31536000;
to:
$tot_age = $tot_age - 31536000;
Upvotes: 4
Reputation: 2772
Use it like this:
while ($tot_age > 536467742) {
$tot_age = $tot_age - 31536000;
if ($tot_age < 536467742 ) {
// do something
break;
}
}
Upvotes: 5