WillSquire
7/31/2015 - 9:23 AM

Is Set

Is Set

/**
 * Returns the first set value out of the arguments given excluding
 * the first arugment, as this is the default value to fall back to if non are found.
 *
 * This function behaves differently from most functions
 * because it can take in an unlimited number of arguments.
 * From the arguments it returns the first set value
 *
 * The first argument is the default value to fall back to as the first parameter,
 * then an unlimited number of arguments after that.
 *
 * @param $default_value
 * @return mixed
 */
function getSet($default_value) {

    $args = func_get_args();
    $args_length = count($args);

    for ($i=1; $i<$args_length; $i++) {
        if (isset($args[$i])) {
            return $args[$i];
            break;
        }
    }

    return $default_value;
}