Re: Array Help

From: Date: Fri, 23 Feb 2001 18:30:03 +0000
Subject: Re: Array Help
Groups: php.general 
Request: Send a blank email to php-general+get-41348@lists.php.net to get a copy of this message
Addressed to: <brian@gfx.cncdsl.com> php-general@lists.php.net ** Reply to note from <brian@gfx.cncdsl.com> Fri, 23 Feb 2001 12:20:12 -0500 > > 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" > ) > ), > "Dirt" => array( > ) > ); I would probably do something like: # reset( $Bikes ) while( list( $BikeType, $Manufacturers ) = each( $bikes )) { echo "$BikeType<BR>\n"; # reset( $Manufacturers ); while( list( $Mfr, $Models ) = each( $Manufacturers )) { echo "&nbsp;&nbsp;$Mfr<BR>\n"; # reset( $Models ); while( list( $Model, $URL ) = each( $Models )) { echo "&nbsp;&nbsp;&nbsp;&nbsp;" . "<A href=\"$URL\">$Model</A><BR>\n"; } } } This would give Road Trek Trek <-- is a link Schwinn Schwinn Fastback Pro <-- is a link Moots VaMoots <-- is a link Lemond Zurich <-- is a link Chambery <-- is a link BuenosAries <-- is a link Tourmalet <-- is a link Dirt If you realy want Trek Schwinn Moots Lemond Trek <-- is a link Schwinn Fastback Pro <-- is a link VaMoots <-- is a link Zurich <-- is a link Chambery <-- is a link BuenosAries <-- is a link Tourmalet <-- is a link You need to do the outer look twice, doing a reset() in it between them, and doing the reset()s I have commented out in the example. Be aware if you go thru the array more than once in the program it will be needed. Rick Widmer Internet Marketing Specialists http://www.developersdesk.com

« previous php.general (#41348) next »