[PHP] Re: can I call a variable... using variables?

2002-07-09 Thread Joseph Szobody

Thanks folks. Worked like a charm


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: can I call a variable... using variables?

2002-07-09 Thread Derick Rethans

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";
> }

Do it like this:

for ($i = 1; $i < 100; $i++) {
 if (${"var$i"} > 0) {
 echo "Yup, $var$1 is greate than 0";
 }
}

Derick


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php