Re: Regarding variable reference
| From: | Jason Wong | Date: | Wed, 16 Jun 2004 14:57:13 +0000 |
| Subject: | Re: Regarding variable reference | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-188400@lists.php.net to get a copy of this message | ||
On Tuesday 15 June 2004 14:14, balaji.ankem@wipro.com wrote:
> 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>";
> }
> }
> ==============================
You've gotten several answers for this already. But you really should be using
arrays rather than variable variables.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
You single-handedly fought your way into this hopeless mess.
*/