note 18271 deleted from language.variables.variable by philip

From: Date: Wed, 16 Mar 2005 01:19:43 +0000
Subject: note 18271 deleted from language.variables.variable by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-86518@lists.php.net to get a copy of this message
Note Submitter: abennett at hq dot panguinbox dot com ---- I found a nice use for variable variable names. It was a nice way arround using a whole bunch of if(){} or case statements. I use it to keep track of timezones. Here is a short example from a long list of timezones function get_offset($zone){ ############## # Time Zones # ############## /*---------------North America & Hawaii------------------*/ $ast = -4; //Atlantic Standard Time | GMT - 4 $adt = -3; //Atalantic Daylight Time | GMT - 3 $est = -5; //Easten Standard Time | GMT - 5 $edt = -4; //Eastern Daylight Time | GMT - 4 $cst = -6; //Central Standar Time | GMT - 6 $cdt = -5; //Central Daylight Time | GMT - 5 $mst = -7; //Moutain Standard Time | GMT - 7 $mdt = -6; //Moutain Daylight Time | GMT - 6 $pst = -8; //Pacific Standard Time | GMT - 8 $pdt = -7; //Pacific Daylight Time | GMT - 7 $hst = -10; //Hawaii Standard Time | GMT - 10 $akst = -9; //Alaska Standard Time | GMT - 9 $akdt = -8; //Alaska Daylight Time | GMT - 8 return $$zone; }//END GET_OFFSET The real thing has all the timezones in the world, so it would be too long to show here. Of course this is part of a function within an object so I do some data-type checking to make sure I am getting what I want from the application, but this saved me alot of time, and it works verry quickly, Hope this was helpful!

« previous php.notes (#86518) next »