Re: can I call a variable... using variables?
| From: | Chris Earle | Date: | Tue, 09 Jul 2002 17:38:07 +0000 |
| Subject: | Re: can I call a variable... using variables? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-106409@lists.php.net to get a copy of this message | ||
Why not just make the form's input names "var[]" then PHP will make them
into an array:
for ($i = 1; $i < 100; $i++)
{
if ($var[$i -1] > 0)
echo "Yup. ". $var[$i - 1] ." is greater than 0.";
}
"Martin Clifford" <MLC1@nrc.gov> wrote in message
news:sd2ae23f.004@nrcgwia.nrc.gov...
You would have to set up a dummy variable to hold the value of two
concatenated variable names. I'd love to write an example, but work is
draggin' me down, sorry!
Martin
>>> "Joseph Szobody" <jszobody@excite.com> 07/09/02 02:12PM >>>
So here's what I'm trying to do:
I have a form submitting dozens of variables called var1, var2, var3, ......
and on and on.
I want to check the value of each of these variables:
for($i = 1;$i < 100; $i++) {
if($var$i > 0)
echo "Yup. $var$i is greater than 0";
}
I get a parse error when trying to run this code. Can I not use $i to call
the $var1, $var2, etc. variables? Is there another way of doing this?
Thanks,
Joseph
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php