RE: [PHP-GENERAL] Accessing variables, with a for-loop

From: Date: Mon, 19 Jun 2000 13:13:40 +0000
Subject: RE: [PHP-GENERAL] Accessing variables, with a for-loop
Groups: php.general 
Request: Send a blank email to php-general+get-2191@lists.php.net to get a copy of this message
-----Original Message----- > From: stephan.schoell@chhos.mail.abb.com > [mailto:stephan.schoell@chhos.mail.abb.com] > Sent: Monday, June 19, 2000 9:00 AM > To: Erlend Strømsvik > Cc: php-general@lists.php.net > Subject: Re: [PHP-GENERAL] Accessing variables, with a for-loop > > > you might write the following test code which worked for me: > <?php > $variable1="a"; > $variable2="b"; > $variable3="c"; > $variable4="d"; > $variable5="e"; > > $max=5; > > for ($i=1;$i<=$max;$i++) { > $var="variable".$i; > $variable[$i]=$$var; //now you have the array you want! > echo $variable[$i]."<br>"; > } > ?> Uh-oh, better make that... $variable[$i] = &$$var; ;) -John

« previous php.general (#2191) next »