Q:

Retrieve array value from PHP

I have this function:
print_r(geoip_record_by_name('php.net'));

This results in:
Array ( 
   [continent_code] => NA 
   [country_code] => US
   [country_code3] => USA 
   [country_name] => United States 
   [region] => CA [city] => Sunnyvale 
   [postal_code] => 94089 
   [latitude] => 37.424900054932 
   [longitude] => -122.0074005127 
   [dma_code] => 807
   [area_code] => 408 
)

I want to retrieve the region value, but 
geoip_record_by_name('php.net')['region'];

gives a blank result.

A:

The following syntax is only supported in PHP >= 5.4:
geoip_record_by_name('php.net')['region'];

If you are using some other version, you will have to do:
$arr = geoip_record_by_name('php.net');
echo $arr['region'];

Docs:

http://php.net/manual/en/language.types.array.php#language.types.array.syntax.accessing

