note 79237 added to function.timezone-identifiers-list

From: Date: Fri, 16 Nov 2007 16:11:31 +0000
Subject: note 79237 added to function.timezone-identifiers-list
Groups: php.notes 
Request: Send a blank email to php-notes+get-132354@lists.php.net to get a copy of this message
Your script was useful, thanks. I made a few small changes to the script to make it work and display the Time Zones properly. The list would display the cities by country but some cities have sub-cities that are not displayed so you would see 8 Argentina's for example and the value would not get the proper Time Zone. With this fix it will display the sub-cites and add them to the value as well. <?php function get_tz_options($selectedzone, $label, $desc = '') { echo '<div class="label"><label for="edited_user_timezone">'.$label.':</label></div>'; echo '<div class="input"><select name="edited_user_timezone">'; function timezonechoice($selectedzone) { $all = timezone_identifiers_list(); $i = 0; foreach($all AS $zone) { $zone = explode('/',$zone); $zonen[$i]['continent'] = $zone[0]; $zonen[$i]['city'] = $zone[1]; $zonen[$i]['subcity'] = $zone[2]; $i++; } asort($zonen); foreach($zonen AS $zone) { extract($zone); if($continent == 'Africa' OR $continent == 'America' OR $continent == 'Antarctica' OR $continent == 'Arctic' OR $continent == 'Asia' OR $continent == 'Atlantic' OR $continent == 'Australia' OR $continent == 'Europe' OR $continent == 'Indian' OR $continent == 'Pacific') { if(!isset($selectcontinent)) { $structure .= '<optgroup label="'.$continent.'">'; // continent } elseif($selectcontinent != $continent) { $structure .= '</optgroup><optgroup label="'.$continent.'">'; // continent } if($city != ''){ if ($subcity != ''){ $city = $city . '/'. $subcity; } $structure .= "<option ".((($continent.'/'.$city)==$selectedzone)?'selected="selected "':'')." value=\"".($continent.'/'.$city)."\">".str_replace('_',' ',$city)."</option>"; //Timezone } else { if ($subcity != ''){ $city = $city . '/'. $subcity; } $structure .= "<option ".(($continent==$selectedzone)?'selected="selected "':'')." value=\"".$continent."\">".$continent."</option>"; //Timezone } $selectcontinent = $continent; } } $structure .= '</optgroup>'; return $structure; } echo timezonechoice($selectedzone); echo '</select>'; echo '<span class="notes"> '.$desc.' </span></div>'; } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 76.101.40.121 ---- Manual Page -- http://www.php.net/manual/en/function.timezone-identifiers-list.php Edit -- https://master.php.net/note/edit/79237 Del: integrated -- https://master.php.net/note/delete/79237/integrated Del: useless -- https://master.php.net/note/delete/79237/useless Del: bad code -- https://master.php.net/note/delete/79237/bad+code Del: spam -- https://master.php.net/note/delete/79237/spam Del: non-english -- https://master.php.net/note/delete/79237/non-english Del: in docs -- https://master.php.net/note/delete/79237/in+docs Del: other reasons-- https://master.php.net/note/delete/79237 Reject -- https://master.php.net/note/reject/79237 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132354) next »