RE: [PHP] Newbie: array help....
| From: | Louis Simpson | Date: | Mon, 22 Jan 2001 16:56:03 +0000 |
| Subject: | RE: [PHP] Newbie: array help.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36052@lists.php.net to get a copy of this message | ||
while ( list($key, $val) = each($bikes["Road"]) ) {
echo "<TD><IMG SRC=\"images/spacer.gif\"
WIDTH=\"25\"
HEIGHT=\"1\" ALT=\"\" BORDER=\"0\"></TD>";
echo "<TD><A HREF=\"$val\"
CLASS=\"menu\">$key</A></TD>";
}
-----Original Message-----
From: Brian V Bonini [mailto:brian@gfx.cncdsl.com]
Sent: Monday, January 22, 2001 8:55 AM
To: PHP Lists
Subject: [PHP] Newbie: array help....
I have this array;
$bikes = array(
"Road" => array(
"Trek 5200" => "URL",
"Schwinn Fastback Pro" => "URL",
"Va Moots" => "url"
),
"Mountain" => array(
"Trek Fuel 90" => "url",
"Schwinn Homegrown" => "url"
),
"BMX" => array(
"Haro Mira 540" => "url",
"Schwinn Powermatic Pro" => "url"
),
"Kids" => array(
"Schwinn Tiger" => "put URL here",
"Schwinn Bumblebee" => "URL"
)
);
and am trying to list only a portion of it.
E.g., how can I reference only $bikes["Road"]
in the snippet below?
Like this:
while ( list($key, $val) = each($bikes["Road"]) ) {
echo "<TD><IMG SRC=\"images/spacer.gif\"
WIDTH=\"25\"
HEIGHT=\"1\" ALT=\"\" BORDER=\"0\"></TD>";
echo "<TD><A HREF=\"$val\"
CLASS=\"menu\">$key</A></TD>";
}
NOT:
while ( list($type, $subarray) = each($bikes) ) {
while ( list($key, $val) = each($subarray) ) {
echo "<TD><IMG SRC=\"images/spacer.gif\"
WIDTH=\"25\"
HEIGHT=\"1\" ALT=\"\" BORDER=\"0\"></TD>";
echo "<TD><A HREF=\"$val\"
CLASS=\"menu\">$key</A></TD>";
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net