<?php
$countries = array (
'London' => 'Europe/London',
'Istanbul' => 'Europe/Istanbul',
'Rome' => 'Europe/Rome',
'Berlin' => 'Europe/Berlin',
'Athens' => 'Europe/Athens',
);
$offsets = array(); // initialize
foreach($countries as $key => $country_offset) { // grouping
$offset = timezone_offset_get( new DateTimeZone( $country_offset ), new DateTime() );
$offsets[$offset][] = array(
'name' => $key,
'offset' => $offset,
'timezome' => $country_offset,
);
}
ksort($offsets); // sort
// presentation
foreach($offsets as $offset => $info) {
echo $offset . ' - ';
$temp = array();
foreach($info as $t) {
$temp[] = $t['name'];
}
echo implode(', ', $temp), "\n";
}
preferences:
43.45 ms | 406 KiB | 5 Q