Re: Variable Syntax Question
| From: | * R&zE: | Date: | Fri, 31 Aug 2001 14:36:36 +0000 |
| Subject: | Re: Variable Syntax Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-65476@lists.php.net to get a copy of this message | ||
<Original message>
From: Ninety-Nine Ways To Die <ninetyninewaystodie@lycos.com>
Date: Fri, Aug 31, 2001 at 10:28:56AM -0400
Message-ID: <NLFHEPCPJCOLJAAA@mailcity.com>
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@datalink.nl
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM HAARLEM
-- Netherlands
--
-- http://www.datalink.nl
-- ««««««««««««««««««««««««