Re: [PHP] traversing multi-dimensional arrays

2005-02-17 Thread Richard Lynch
blackwater dev wrote: > 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

Re: [PHP] traversing multi-dimensional arrays

2005-02-17 Thread Brent Baisley
Forget about the $cars array. The array "key" in the $models array will be your car list. $cars=array("ford","chevy"); $models=array("ford"=>array("ranger","escape"),"chevy"=>array("malibu"," tahoe")); //Loop through first level of array, getting car maker foreach($models as $carmaker=>$models)

[PHP] traversing multi-dimensional arrays

2005-02-17 Thread blackwater dev
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