If you want to iterate over a two-dimensional, sparse array, and want to first display every first element, then every second and so on, you can use this code: $fruits = array ( "fruits" => array ( "a" => "orange", "b" => "banana", "c" => "apple" ), "numbers" => array ( 1, 2, 3, 4, 5, 6 ), "holes" => array ( "first", 5 => "second", "third", 10 => "fourth", ) );$done = False;while ($done == False) { $done = True; // Important: &$val has to be a reference (use the &), // if you don't, the internal counter of $val will be // re-initialized each time and you loop over the first elements // for eternity. foreach($fruits as $key => &$val) { if (list($inner_key, $inner_val) = each(&$val)) { $done = False; echo "$key : : $inner_key => $inner_val <br> \n"; } }}NOTE: this is just a quick hack, if you know a better way, post it!