Home > Archive > PHP DB > January 2005 > Re: [PHP-DB] foreach()
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PHP-DB] foreach()
|
|
|
| Try this : --
$z = array('foo' => array('bar')), 'dis' => array('dat'));
while (list($key, $val) = each($z)) {
echo "<BR>$key $val";
}
----- Original Message -----
From: "Yemi Obembe" <fickledreams@yahoo.com>
To: <php-db@lists.php.net>
Sent: Monday, January 31, 2005 9:47 AM
Subject: [PHP-DB] foreach()
>
>
> Hi folks.
> wat can be done to dis:
>
> $z = array('foo' => array('bar')), 'dis' => array('dat'));
> foreach(//???) {
> echo "//??? <br> //?? </p>";
> }
>
> to output dis:
>
> foo
> bar
>
> dis
> dat
>
>
>
>
>
> ---------------------------------
>
> A passion till tomorrow,
> Opeyemi Obembe | ng.clawz.com
>
>
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> The all-new My Yahoo! - What will yours do?
| |
| Graeme 2005-01-31, 8:56 am |
| or even...
$z = array('foo' => array('bar'), 'dis' => array('dat'));
while (list($key, $val) = each($z)) {
echo "$key<BR> $val[0]<p>";
}
You need to remove the superfluous close bracket on after bar, and the
val is an array hence $val[0] to get the element displayed.
graeme.
Han wrote:
> Try this : --
>
> $z = array('foo' => array('bar')), 'dis' => array('dat'));
> while (list($key, $val) = each($z)) {
> echo "<BR>$key $val";
> }
>
>
>
>
> ----- Original Message ----- From: "Yemi Obembe" <fickledreams@yahoo.com>
> To: <php-db@lists.php.net>
> Sent: Monday, January 31, 2005 9:47 AM
> Subject: [PHP-DB] foreach()
>
>
>
>
--
Experience is a good teacher, but she sends in terrific bills.
Minna Antrim
|
|
|
|
|