PHP checking for array key or using default value I currently use this code pattern fairly frequently

if(array_key_exists('possible_key', $array)) {
    $my_variable = $array['possible_key'];
} else {
    $my_variable = 'my default value';
}


Is there a better way to be writing this?
One quick change you can do is making use of ternary operator instead of writing if else block.

$my_variable = array_key_exists('possible_key', $array) 
               ? $array['possible_key'] 
               : 'my default value';