1--TEST-- 2Test DateTimeZone::getLocation() 3--CREDITS-- 4marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br 5--FILE-- 6<?php 7$countryCode = array("??"); 8$countryCodeTest = array("AU", "CA", "ET", "AF", "US", "KZ", "AM"); 9 10foreach (DateTimeZone::listAbbreviations() as $value) { 11 if (NULL != $value[0]['timezone_id']) { 12 $timeZone = new DateTimeZone($value[0]['timezone_id']); 13 $timeZoneArray = $timeZone->getLocation(); 14 if (false === $timeZoneArray) { 15 continue; 16 } 17 18 if (!in_array($timeZoneArray['country_code'], $countryCode) && NULL != $timeZoneArray['country_code']) { 19 array_push($countryCode, $timeZoneArray['country_code']); 20 21 if(in_array($timeZoneArray['country_code'], $countryCodeTest)){ 22 print_r($timeZoneArray); 23 } 24 } 25 } 26} 27?> 28--EXPECTF-- 29Array 30( 31 [country_code] => %s 32 [latitude] => %f 33 [longitude] => %f 34 [comments] => %s 35) 36Array 37( 38 [country_code] => %s 39 [latitude] => %f 40 [longitude] => %f 41 [comments] => %s 42) 43Array 44( 45 [country_code] => %s 46 [latitude] => %f 47 [longitude] => %f 48 [comments] => %s 49) 50