Re: [PHP] Variable Syntax Question From: * R&zE: (renze <email protected>)
Date: 08/31/01

<Original message>
From: Ninety-Nine Ways To Die <ninetyninewaystodie <email protected>>
Date: Fri, Aug 31, 2001 at 10:28:56AM -0400
Message-ID: <NLFHEPCPJCOLJAAA <email protected>>
Subject: [PHP] Variable Syntax Question

> I have a form that reads in a couple variables via:
>
> <input type=textbox name=bob1>
> <input type=textbox name=bob2>
> <input type=textbox name=bob3>
> <input type=textbox name=bob4>
>
> Now... I want to read in those variables in something like the following:
>
> for($i=1;$i<4;$i++) {
> echo "$bob$i";
> }
>
> BUT.... that obviously doesn't work, it simple prints 1, so how to I make it echo the value of the variable bob1?
>
> -Hass

</Original message>

<Reply>

for ($i = 1; $i < 4; $i++) {
  $myVar = "bob$i";
  print ($$myVar);
}

</Reply>

-- 

* R&zE:

-- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze <email protected> -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>