Re: variable variables

From: Date: Thu, 17 Jan 2002 17:16:33 +0000
Subject: Re: variable variables
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-80942@lists.php.net to get a copy of this message
On Thu, 17 Jan 2002 11:11:43 -0500, you wrote: >I can not wrap my head around variable variables today, not awake yet or >something. > >For instance I trying something like this: > >while ($i<$loopcounter) { > $temp = "size"; > $valueofsize = $$temp$i; > $i++; >} What about $i = 0; // set the start (or use for()) while ($i<$loopcounter) { > $temp = "size". $i; // $temp = 'size1', 'size2'... $valueofsize = $$temp; $i++; # untested code, should be OK though } No messing around with evals neccessary. Alister

« previous php.general (#80942) next »