Skip to content

Instantly share code, notes, and snippets.

@mircobabini
Created December 8, 2012 15:22
Show Gist options
  • Save mircobabini/4240728 to your computer and use it in GitHub Desktop.
Save mircobabini/4240728 to your computer and use it in GitHub Desktop.
returns the first true-valued value
<?
/**
* returns the first true-valued value
*
* @param mixed $if
* @param mixed $or
* @return mixed
*
* @package Handframe/Tool/Function
* @author Mirco Babini <[email protected]>
* @license http://creativecommons.org/licenses/by-nc/3.0/
*/
function ifor ($if, $or)
{
$args = func_get_args ();
do {
$arg = array_shift ($args);
if ($arg) return $arg;
}
while (sizeof ($args) > 0);
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment