Re: eval()
| From: | Miguel Cruz | Date: | Mon, 20 May 2002 17:39:35 +0000 |
| Subject: | Re: eval() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98482@lists.php.net to get a copy of this message | ||
On Mon, 20 May 2002, jtjohnston wrote:
> I know I'm not doing this right, but ..
>
> What I want to do is display the value of $q1 through $q3.
> How? I can't get eval() to do it, can I?
>
> for ($i = 1; $i <= 3; $i++)
> {
> $x= eval ("\$q".$i);
> echo"<b>$x</b>\n";
> echo"<br><input type=\"hidden\" name=\"a".$i."\"
> value=\"\">\n";
> }
eval() is for running code, not parsing strings.
Try something like:
for ($i = 1; $i <= 3; $i++)
{
$var = "q$i";
print "<br><input type='hidden' name='{$$var}'>\n";
}
Or use arrays.
miguel