Re: Question...
| From: | Lars Torben Wilson | Date: | Fri, 11 Aug 2000 19:48:10 +0000 |
| Subject: | Re: Question... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11392@lists.php.net to get a copy of this message | ||
Dustin Leggans writes:
> Hello..
>
> I am trying to assign an HTML form NAME to "$f[]" from within the PHP
> program.. It does not seem to be working correctly.. I believe that php is
> turning the "$" into some sort of ascii, or URL encoded character and
> therefore php will not process it as an array
>
> Here is an example of how my program looks now:
>
> while (list ($key, $val) = each ($fields)) {
> print "$key : <input type=\"text\" size=\"30\"
> MAXLENGTH=\"60\"
> name=\$f[] value=\"$val\"><br>";
> }
>
>
> Any suggesstions...
>
> Thanks,
> Dustin
You don't need the '$' there, since this is HTML code you're
writing. The only difference between using an array and a scalar in
this case is the addition of the square brackets after the variable
name in the <input> code, which tells PHP to interpret multiple values
as multiple array members. In short, you should end up with something
like this:
while (list ($key, $val) = each ($fields)) {
print " $key:<input type=\"text\" size=\"30\"
MAXLENGTH=\"60\" name=\"f[]\" value=\"$val\"><br>\n";
}
Hope this helps,
Torben
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+