Re: Newbie help w/ dynamic variables

From: Date: Thu, 14 Feb 2002 18:10:54 +0000
Subject: Re: Newbie help w/ dynamic variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-84776@lists.php.net to get a copy of this message
you can create variables dinamically like that $counter=0; foreach ($some_arr as $key=>$value){ $("your_dyn_var".$counter}="some html code"; $counter++; } So if you have 5 iterations you will have in the namespace new 5 variables : from $your_dyn_var0 to $your_dyn_var4 When you want to show them in the parsed html do: $counter=0; while(isset(${"your_dyn_var".$counter++})) echo ${"your_dyn_var".($counter-1);} or for ($tmp_count=0;$tmp_count<$counter;$counter++){ echo ${"your_dyn_var".$counter"};} Best regards Andrey Hristov ----- Original Message ----- From: Honey House Designs To: php-dev@lists.php.net Sent: Thursday, February 14, 2002 7:56 PM Subject: [PHP-DEV] Newbie help w/ dynamic variables I would like to dynamically create variables in my WHILE loop that then can actually have php parsed html code stored inside them and then have the value of that variable run when after php is run and as the html is evaluated at page loading... Any suggestions? And be gentle... I am a newbie! Tx, tb

« previous php.general (#84776) next »