Re: dynamic variables in a while loop?
| From: | Rick Emery | Date: | Wed, 15 Jan 2003 13:03:23 +0000 |
| Subject: | Re: dynamic variables in a while loop? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131690@lists.php.net to get a copy of this message | ||
for($ii=1; $ii<20; $ii++)
{
$helpz = "help$ii";
if(${$helpz} == "yes)
{
}
else
{
}
}
----- Original Message -----
From: "Philipp Hartmann" <heart@gsdh.org>
To: <php-general@lists.php.net>
Sent: Wednesday, January 15, 2003 6:50 AM
Subject: [PHP] dynamic variables in a while loop?
Hi everyone.
I am more of an ActionScript person, but I have to do this one in php.
Should
be easy for everyone familiar with php syntax...
Here is what I want to do:
I am getting several variables into a Php Script such as:
help1 = "yes" / "no"
help2 = "yes" / "no"
.
.
.
helpX = "yes" / "no"
I need to check whether the variable is true or false, and according to that
add
1 to a counter variable.
Something like this I'd do in ActionScript, but dont know about php
[CODE]
$i = 0;
While (++$i <= 8) {
if ([help]+$i=="yes"){ // this line produces an error...
$counterYes += counterYes;
}
}
[/CODE]
Do I have to initialize all variables before I can use them in php?
Thank you very, very much for your time and your help!!
Philipp
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php