RE: GLOBALS...

From: Date: Thu, 02 Nov 2000 02:13:41 +0000
Subject: RE: GLOBALS...
Groups: php.general 
Request: Send a blank email to php-general+get-23295@lists.php.net to get a copy of this message
---------------------------------------------------------------------------- ----------------- Disclaimer: The information contained in this email is intended only for the use of the person(s) to whom it is addressed and may be confidential or contain legally privileged information. If you are not the intended recipient you are hereby notified that any perusal, use, distribution, copying or disclosure is strictly prohibited. If you have received this email in error please immediately advise us by return email at postmaster@normandy.com.au and delete the email document without making a copy. ---------------------------------------------------------------------------- ----------------- Vladimir, You'd be a lot better off using Arrays. If you want it to be GLOBAL it works a lot better. When you dceide not to use a global variable and pass it via a function you can also pass the one array much more easily. ie: $test[1] = "foo"; $test[2] = "bar" . . $test[10] = "Vladimir"; while(list($key,$value) = each($GLOBALS["test"])){ echo "$key $value <br>\n"; } or have a function that is similiar: function showall($ary){ while(list($key,$value) = each($ary)){ echo "$key $value <br>\n"; } } and call it via showall($test); No where near as messy and much easier to change if someone decides that they want 12 items instead of 10. Its also more reusable and you dont have as many globals to worry about. mn Mark Nold markn@enspace.com <mailto:markn@enspace.com> Senior Consultant   Change is inevitable, except from vending machines. -----Original Message----- From: Vladimir Novakovic [mailto:vnovakov@ai.sanu.ac.yu] Sent: Wednesday, November 01, 2000 2:53 PM To: php-general@lists.php.net Subject: GLOBALS... I need to have several globals from $GLOBALS[test0] until $GLOBALS[test10], but under regular while/endwhile loops, will anyone help me and send some example? How to do that with regular variables too? For example I need to have varibale from $stn0 until $stn10. Is it possible to use something like: $stn$i What do I need - example: $num=10 $i=0; while($i < $num): $GLOBALS[phone0...10] = $stn0...10; $i = $i + 1; endwhile; thanks in advance, Vladimir

« previous php.general (#23295) next »