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

2001-01-22 Thread Brian Clark


Hello Brian, 

(BVB == "Brian V Bonini") [EMAIL PROTECTED] writes:

BVB That's what I thought, which seemed to be the obvious
BVB however, when I tried that it returns an error.

BVB "Warning: Variable passed to each() is not an array or object in pagetop.inc
BVB on line 105"

?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($type,) = each($bikes))
{
while(list($model,$url) = each($bikes[$type]))
{
print "Type: $typebr";
print "Model: $modelbr";
print "URL: $urlbr";
print "p";
}
}

?

-Brian
--
Point not found. (A)bort (R)eread (I)gnore.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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

2001-01-22 Thread Brian V Bonini

I apparently misunderstood your implementation,
your right, it does work perfectly Thank you!

 -Original Message-
 From: Ignacio Vazquez-Abrams [mailto:[EMAIL PROTECTED]]
 Sent: Monday, January 22, 2001 12:27 PM
 To: Brian V Bonini
 Cc: PHP Lists
 Subject: RE: [PHP] Newbie: array help
 
 
 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"]))
 {
 ?
 tdimg src="images/spacer.gif" width="25" height="1" alt="" 
 border="0" //td
 tda href="?=$key?" class="menu"?=$val?/a/td
 ?php
 };
 
 ?
 /table
 
 Works perfectly.
 
 -- 
 Ignacio Vazquez-Abrams  [EMAIL PROTECTED]
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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

2001-01-22 Thread Louis Simpson

You don't need the embedded while loop

 while ( list($key, $val) = each($bikes["Road"]) ) {
 echo "TDIMG SRC=\"images/spacer.gif\" WIDTH=\"25\"
 HEIGHT=\"1\" ALT=\"\" BORDER=\"0\"/TD";
 echo "TDA HREF=\"$val\"
 CLASS=\"menu\"$key/A/TD";
 }
-Original Message-
From: Brian V Bonini [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 22, 2001 9:16 AM
To: Ignacio Vazquez-Abrams
Cc: PHP Lists
Subject: RE: [PHP] Newbie: array help


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:[EMAIL PROTECTED]]
 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 "TDIMG SRC=\"images/spacer.gif\" WIDTH=\"25\"
  HEIGHT=\"1\" ALT=\"\" BORDER=\"0\"/TD";
  echo "TDA HREF=\"$val\"
 CLASS=\"menu\"$key/A/TD";
  }
  }
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]