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

From: Date: Mon, 22 Jan 2001 17:26:35 +0000
Subject: RE: [PHP] Newbie: array help....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36031@lists.php.net to get a copy of this message
On Mon, 22 Jan 2001, Brian V Bonini wrote: > 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, > I reimplemented your snippet from first principles, and here's what I came up with (reformatted and XHTMLized): <table> <?php $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" ) ); while (list($val, $key)=each($bikes["Road"])) { ?> <td><img src="images/spacer.gif" width="25" height="1" alt="" border="0" /></td> <td><a href="<?=$key?>" class="menu"><?=$val?></a></td> <?php }; ?> </table> Works perfectly. -- Ignacio Vazquez-Abrams <ignacio@openservices.net>

« previous php.general (#36031) next »