Q:

PHP - Java opt() for arrays to set fallback value

I wonder if there is a PHP solution for Java's opt() function. 
For example: In some cases I get a $_GET parameter, in some not.  I'd like to to something like this:
$myVar = $_GET.opt('myParam', 'whatever');

If myParam is not set, myVar is set to the string "whatever". 
Any ideas? 
Thanks! 

A:

function ifnull(array &$array, $key, $default){
    if(!isset($array[$key])){
        $array[$key] = $default;
    }

    return $array[$key];
}

OR
function ifnull(array &$array, $key, $default){
    return isset($array[$key]) ?  $array[$key] : $default;
}

