Array Help

From: Date: Fri, 23 Feb 2001 17:20:12 +0000
Subject: Array Help
Groups: php.general 
Request: Send a blank email to php-general+get-41335@lists.php.net to get a copy of this message
I've tried and tried and tried.... ;-) I have this array; $bikes = array( "Road" => array( "Trek" => array( "Trek 5200" => "road.php?brand=t5200" ), "Schwinn" => array( "Schwinn Fastback Pro" => "road.php?brand=schfp" ), "Moots" => array( "VaMoots" => "road.php?brand=vamoots" ), "Lemond" => array( "Zurich" => "road.php?brand=zurich", "Chambery" => "road.php?brand=chambery", "BuenosAries" => "road.php?brand=bueno", "Tourmalet" => "road.php?brand=tourmalet" ) ) ); I'm trying to list the four brands followed by each brands model and URL. I.E. Trek Schwinn Moots Lemond Trek 5200 Schwinn Fastback Pro etc.... What am I doing wrong here, if ($cat == 'bikes') { while ( list($type,) = each($bikes["Road"])) { echo "<TD><A HREF=\"$type\" CLASS=\"menu\">$type</A></TD>\n"; } while ( list($typ,) = each($bikes["Road"])) { while (list($val, $key)=each($bikes["Road"][$typ])) { echo "<TD><IMG SRC=\"images/spacer.gif\" WIDTH=\"25\" HEIGHT=\"1\" ALT=\"\" BORDER=\"0\"></TD>\n"; echo "<TD><A HREF=\"$key\" CLASS=\"menu\">$val</A></TD>\n"; } } } The first while loop works but not the second pair. I thought $typ would contain the brand on each pass but this returns nothing....... Help... :( -Brian

« previous php.general (#41335) next »