A basic check if an array element exists:
$foo = isset($country_data['country']) ? $country_data['country'] : '';
That feels really verbose and I'm now asking is there a shorter way to do that?
I could suppress the error with @
:
$foo = @$country_data['country']
But that seems wrong somehow...
I know that with variables you can do something like this:
$foo = $bar ?: '';
But that doesn't work with isset()
.