Re: Variable Syntax Help Needed PLEASE!!
| From: | Geoff Caplan | Date: | Mon, 13 Nov 2000 02:26:09 +0000 |
| Subject: | Re: Variable Syntax Help Needed PLEASE!! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24899@lists.php.net to get a copy of this message | ||
Jeff
You simply nest your "foreach" loops, as follows:
foreach ($i as $value1)
{
foreach ($value1 as $key=> value2)
{
"print "$key: $value2<br>";
}
print ("<br">;
}
Or something like that. It is late and I don't have time to check it... Hope
this helps.
By the way, foreach loops only work with PHP4.
Geoff Caplan
British Goldsmiths
geoff@britishgoldsmiths.com
----- Original Message -----
From: "Jeff Lacy" <jeffdl@mn.mediaone.net>
To: <php-general@lists.php.net>
Sent: Sunday, November 12, 2000 11:14 PM
Subject: [PHP] Variable Syntax Help Needed PLEASE!!
Hello everybody,
I have a hopefully simple question. Assume I have an array like so:
$i1[0] = "blah";
$i1[1] = "barf";
$i2[0] = "hello";
$i2[1] = "there";
$i3[0] = "good";
$i3[1] = "afternoon";
.....
$x is the number of arrays above, or in this case 3. I also have a for loop
like:
for ($a = "1"; $a <= $x; $a++) {
....
}
How would I refer to $i1[0] and $i1[1] and $i2[0] and $i2[1] and $i3[0] and
$i3[1] in my for loop? Thanks in advance :-D
Jeff