It's called Variable Variables. for($i = 1; $i < 100; $i++) { $varname = "var" . $i; if($$varname > 0) echo "Yup."; }
Adam Voigt [EMAIL PROTECTED] On Tue, 2002-07-09 at 14:12, Joseph Szobody wrote: > 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php