Reputation: 10162
is that possible to do that?
<?php if($limit != "0" && $num_down < $limit || $limit == "0") {
//stuff
}
?>
i need to check if limit equals to 0 or if it is not, if $num_down is under limit.
Thank you
Upvotes: 0
Views: 1794
Reputation: 371
Your question can be a little confusing. But if i try to analyse it seriously, you mean:
IF $num_down is under $limit.
THEN
You want to check if $limit is EQUAL to 0 ?
Is that right ?
If so then the code should go like this.
if ($num_down < $limit) {
if ($limit == 0) { // <----If $limit is not EQUAL to 0 it will just not enter here
// stuff
}
}
Depending of what you really need, a " if " into a " if " , could be your solution
Upvotes: 0
Reputation: 61469
Don't make it any more complicated than necessary:
if ($limit == 0 || $num_down < $limit) {
...
}
This works because the logical or (||
) evaluates to true if either or both of its arguments evaluate to true.
Upvotes: 4
Reputation: 526
if( ($limit != 0 && $num_down < $limit) || $limit == 0 )
{
whateves();
}
You can do it this way if you want to evaluate the first condition before the second. You can also use another if branch.
Check out the manual page for operator precedence
Upvotes: 1