Re: Regarding variable reference
| From: | Ulrik S. Kofod | Date: | Tue, 15 Jun 2004 07:25:08 +0000 |
| Subject: | Re: Regarding variable reference | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-188302@lists.php.net to get a copy of this message | ||
balaji.ankem@wipro.com sagde:
>
> 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>";
}
}