/ Published in: PHP
Can be used like SQL COALESCE, IFNULL or for defaulting if a value is falsy
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function firstTruthy(/*$value1, $value2, $valueN...*/) { foreach ($args as $a) { if (!!$a) { return $a; } } return null; }