I’m trying to rephrase the a conditional to drop a { .. } statement (to make the code less indented).
Currently I have:
while($something){
if((strcasecmp($str1, $str2) === 0)
|| (isset($arr[0]) && strcasecmp($str3, $str4) === 0)){
// a lot of code here...
break;
}
}
With the inversed IF condition it should look like:
while($something){
if((strcasecmp($str1, $str2) !== 0)
&& (empty($arr[0]) && strcasecmp($str3, $str4) !== 0))
continue;
// a lot of code here...
break;
}
But it doesn’t work. My code and the break statement get executed when they shouldn’t.
What am I doing wrong here.
Here
The
&&must be||.I for myself would keep the first variant, because it’s slightly more straight-forward.
Update: OK, as I thought about it the
break;makes me wonder. You want to get rid of one intendation?And know some micro-optimization 🙂 (
!strcasecmp()means, that they are equal, except maybe the case)I hope the paranthesis matches.