This question already has an answer here:
I am creating a timezone in php but I am getting error. Kindly check my code:
<?php
function tz_list() {
$zones_array = array(); // HERE T_VARIABLE Error
$timestamp = time(); // HERE T_VARIABLE Error
foreach(timezone_identifiers_list() as $key => $zone) {
date_default_timezone_set($zone);
$zones_array[$key]['zone'] = $zone;
$zones_array[$key]['diff_from_GMT'] = 'UTC/GMT ' . date('P',
$timestamp);
}
return $zones_array;
}
?>
<div style="margin-top: 20px;">
<select style="font-family: 'Courier New', Courier, monospace; width: 450px;">
<option value="0">Please, select timezone</option>
<?php foreach(tz_list() as $t) { ?>
<option value="<?php print $t['zone'] ?>">
<?php print $t['diff_from_GMT'] . ' - ' . $t['zone'] ?>
</option>
<?php } ?>
</select>
</div>
I am getting Syntax T_VARIABLE Error but I recheck and look like everything is fine, kindly check and please suggest what I am doing wrong.
</div>