traversing multi-dimensional arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

What is the best way to do this?  I have two arrays:

$cars=array("ford","chevy");
$models=array("ford"=>array("ranger","escape"),"chevy"=>array("malibu","tahoe"));

then I need to traverse both arrays:

   foreach ($cars as $car){
		   //now I need to get into the models array and echo out all of the
models that
                 //coincide with the specific car so it should print
out ford-ranger
                //I basically want to do this but can't
               //how can I get into this second array without looping
through the whole thing each time?
   foreach($cars[$car] as $model){
          
              }

		  }

Thanks!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux