Ulrik S. Kofod wrote:

[EMAIL PROTECTED] 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;");

Why are you using eval? Eval is slow and is a hack... Just do: $y = $$x;

        if(isset($y))
        {
                echo "<p>$x:$y</p>";
        }
}


--
paperCrane <Justin Patrin>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to