4 ms·
no, but it all comes to the complexity of the operation. Like the article said, something like this is better than an if else loop: $variable == $x ? $y : $z;
by PunchTornado 8y ago
no, but it all comes to the complexity of the operation.
Like the article said, something like this is better than an if else loop: $variable == $x ? $y : $z;
But if you write stuff like this:
$variable == $x ? ($x == $y ? array_merge($x, $y, $z) : $x) : $y;
I am going to be annoyed. In the second case, please use if else.
- esdkl22 8y agoYou're correct. I didn't look closely enough at the finalized piece of code. I misinterpreted and thought the offer was unsatisfied with the original, appropriate use for a ternary operator ($variable == $x ? $y : $z)