Created
December 8, 2012 15:22
-
-
Save mircobabini/4240728 to your computer and use it in GitHub Desktop.
returns the first true-valued value
This file contains 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
<? | |
/** | |
* 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