Re: GLOBALS...

From: Date: Wed, 01 Nov 2000 08:58:33 +0000
Subject: Re: GLOBALS...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23124@lists.php.net to get a copy of this message
On Wed, 01 Nov 2000, Vladimir Novakovic wrote: > 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; Hi! If you have n globals and n "normal" variables, named glob0 - globn-1 and var0 - varn-1, respectively, you do this: for ($i=0 ; $i < $n ; $i++) { $GLOBALS["glob" . $i]= ${"var" . $i}; } Hope this helps, Cheers, Marco

« previous php.general (#23124) next »