Re: Regarding variable reference
| From: | Justin Patrin | Date: | Tue, 15 Jun 2004 16:13:51 +0000 |
| Subject: | Re: Regarding variable reference | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-188324@lists.php.net to get a copy of this message | ||
Ulrik S. Kofod wrote:
balaji.ankem@wipro.com sagde:Why are you using eval? Eval is slow and is a hack... Just do: $y = $$x;Hi, I have variables called Cookie1 to Cookie35. I would like to print the values of Cookie1 to Cookie35 using for loop. Could anybody correct the below code to print the variables. =============================for($i=1;$i<34;$i++) { $x="Cookie".$i; if(isset($$x)) { echo "<p>$x:$$x</p>"; } }for($i=1;$i<34;$i++) {$x="Cookie".$i; eval("\$y = \$$x;");
if(isset($y))
{
echo "<p>$x:$y</p>";
}
}
--
paperCrane <Justin Patrin>