I found the following code, which prints all the elements of an array fine. How can I modify it to print a key one time and then all the values corresponding to the key, then another key, then all values corresponding to key? I also would like to modify it so it only prints the first 9 values (no more than this) for each key.
function printAll($a) {
if (!is_array($a)) {
echo $a, ' ';
return;
}
foreach($a as $v) {
printAll($v);
}
}