RE: [PHP] Newbie: array help....

From: Date: Mon, 22 Jan 2001 17:15:48 +0000
Subject: RE: [PHP] Newbie: array help....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36026@lists.php.net to get a copy of this message
That's what I thought, which seemed to be the obvious however, when I tried that it returns an error. "Warning: Variable passed to each() is not an array or object in pagetop.inc on line 105" PHP Version 4.0B2 BSDI BSD/OS 4.0.1 Zend Engine v0.90, > -----Original Message----- > From: Ignacio Vazquez-Abrams [mailto:ignacio@openservices.net] > Sent: Monday, January 22, 2001 11:56 AM > To: Brian V Bonini > Cc: PHP Lists > Subject: Re: [PHP] Newbie: array help.... > > > each($bikes["Road"]) > > > > On Mon, 22 Jan 2001, Brian V Bonini wrote: > > > 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? > > > > 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>"; > > } > > } > >

« previous php.general (#36026) next »