PHP question about multidimensional array

My array looks like this:\[code\]Array ( [Bob] => Red [Joe] => Blue )\[/code\]But it could be any number of people, like this:\[code\]Array ( [Bob] => Red [Joe] => Blue [Sam] => Orange [Carla] => Yellow)\[/code\]Basically I want PHP to take this array and echo it so that it comes out looking like:\[code\]Bob - RedJoe - BlueSam - OrangeCarla - Yellow\[/code\]I know I need to loop through the array, this is what I tried:\[code\]for ($row = 0; $row < count($array); $row++) {echo $array[0] . " - " . $array[1];}\[/code\]I get the following error: Undefined offset: 0, Undefined offset: 1I realize that this doesn't work because I'm trying to use index's when the values of the array are strings. Is there any way I can use positional index's like this with a multidimensional array that only contains strings?Thanks
 
Back
Top