note 122940 deleted from function.timezone-identifiers-list by salathe

From: Date: Sun, 24 Oct 2021 22:27:01 +0000
Subject: note 122940 deleted from function.timezone-identifiers-list by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217110@lists.php.net to get a copy of this message
Note Submitter: jd dot aus dot st at gmail dot com ---- to create a list of all timezones using the code as the value, use the below: <?php function select_Timezone($selected = '') { $OptionsArray = timezone_identifiers_list(); $select= '<select name="SelectContacts">'; while (list ($key, $row) = each ($OptionsArray) ){ $select .='<option value="'.$key.'"'; $select .= ($key == $selected ? ' selected' : ''); $select .= '>'.$row.'</option>'; } // endwhile; $select.='</select>'; return $select; } ?> The above func takes one optional parameter which is the selected timezone, example for sydney Australia would be: <?php echo select_Timezone(313) . '<br>'; ?> If you wanted to just display the list (no pre-selected option): <?php echo select_Timezone() . '<br>'; ?> much easier to understand than the other options on this page (although not as flexible).

« previous php.notes (#217110) next »