RE: [PHP] How to construct variable names ?!

From: Date: Sun, 26 Nov 2000 09:58:49 +0000
Subject: RE: [PHP] How to construct variable names ?!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27251@lists.php.net to get a copy of this message
use the following: loop { $label= "variable".$i; $i++; } get the content of the variables: loop { $label = "variable".$i; echo ${$label}; $i++; } > -----Original Message----- > From: Juergen Hall [mailto:jyrgen@gmx.de] > Sent: Sunday, November 26, 2000 10:55 AM > To: Morten Dreier; php-general@lists.php.net > Subject: Re: [PHP] How to construct variable names ?! > > > > > > >I have a string array like > > >$fuse > > >and get its values by > > >$fuse[0], $fuse[1], ... and so on > > > > > >how do i generate corresponding > > >variables like > > >$fuse1, $fuse2, ...and so on > > > > I use > > eval("\$fuse$i=$something;"); > > where $i is the counter. > > > > cool, thanks. > i didn't consider eval. > The backslash is for preventing the parser > from translating "$fuse$i" and $something > into nonsense, i assume. > jyrgen > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#27251) next »