note 1241 deleted from Variables from outside PHP by ronabop
| From: | ronabop@php.net | Date: | Fri, 25 Aug 2000 08:24:01 +0000 |
| Subject: | note 1241 deleted from Variables from outside PHP by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-3129@lists.php.net to get a copy of this message | ||
further on assigning array through form submition (<input name="foobar[]">)
here's the code again (with &lt; and &gt; placed in the code... sorry)
first form creation code
<pre>
for ($i=0;$i<5;$i++) {
for ($r=0;$r<5;$r++) {
echo "<input type=hidden name="foobar[$i][$r]"
value="$i|$r">n";
}
}
</pre>
first form proccessing code
<pre>
for ($i=0;$i<5;$i++) {
for ($r=0;$r<5;$r++) {
echo $foobar[$i][$r] . " - ";
}
}
</pre>
result<br>
- - - - (....etc)<br>
second form creation code
<pre>
for ($i=0;$i<5;$i++) {
for ($r=0;$r<5;$r++) {
echo "<input type=hidden name="foobar<b>$i[$r]</b>"
value="$i|$r">n";
}
}
</pre>
second form proccesing code
<pre>
for ($i=0;$i<5;$i++) {
$myFoob = "foobar" . $i;
for ($r=0;$r<5;$r++) {
echo ${$myFoob}[$r] . " - ";
}
}
</pre>
result:<br>
0|0 - 0|1 - 0|2 .... - 4|3 - 4|4 -