Created
February 3, 2017 21:48
-
-
Save jbnv/63771fc241570ce5b61f936f4d7499c5 to your computer and use it in GitHub Desktop.
Return the first value that isn't unset, null or empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return the first value that isn't unset, null or empty. | |
function coalesce() { | |
foreach(func_get_args() as $arg) { | |
if (!empty($arg)) return $arg; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment