Re: How to construct variable names ?!
| From: | Ignacio Vazquez-Abrams | Date: | Sun, 26 Nov 2000 19:47:49 +0000 |
| Subject: | Re: How to construct variable names ?! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27275@lists.php.net to get a copy of this message | ||
On Sun, 26 Nov 2000, Juergen Hall wrote:
> > On Sat, 25 Nov 2000, Juergen Hall wrote:
> >
> > > 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
> > >
> > > ???
> > > jyrgen
> > >
> >
> > I've seen all sorts of creative responses to this question (parse_str(),
> > eval(), etc.), but I think you're looking for something like the following:
> >
> > for ($i=0; $i<count($fuse); ++$i)
> > {
> > ${"fuse".$i}=$fuse[$i];
> > };
> >
>
> exactly, but i was not sure about the
> expression $("$fuse" $i)...If it will be
> understood the way we want.
> I guess it will only work with eval()
> jyrgen
>
The way that expression works is that it concatenates "fuse" and the contents
of $i and then uses that as the name of the variable.
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>