Skip to content

Instantly share code, notes, and snippets.

@jbnv
Created February 3, 2017 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbnv/63771fc241570ce5b61f936f4d7499c5 to your computer and use it in GitHub Desktop.
Save jbnv/63771fc241570ce5b61f936f4d7499c5 to your computer and use it in GitHub Desktop.
Return the first value that isn't unset, null or empty.
// 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