Re: creating variable names on the fly

From: Date: Fri, 18 Aug 2000 18:57:35 +0000
Subject: Re: creating variable names on the fly
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-12519@lists.php.net to get a copy of this message
load the values into an array, then loop through the array: $array = array (1, 2, 3, 17); for ($i = 1; $i <= 4; $i++) { print $array[$i]; } or foreach ($array as $v) { print $v; } ----- Original Message ----- From: "Robert J. Cissell" <rcissell@tampabay.rr.com> To: "PHP List" <php-general@lists.php.net> Sent: Friday, August 18, 2000 1:37 PM Subject: [PHP] creating variable names on the fly I have a list of variables e1, e2, e3, etc. I want to write some code like this: $count = 1; while($count <=4) { <set the value of element equal to e+count> print($element); } How would I do the first line in the while loop? Thanks. Robert

« previous php.general (#12519) next »