The outer 'if is_array' is unnecessary, unless you're trying
to protect the function against accidentally being called
with a non-array parameter.
But the function as written should work fine. You detect
the end of the loop within the 'while...each' loop: when
you get to the end of the array you simply don't make
another recursive call to printToFlash() so you're done!
When I test it this way:
$inner = array( 'a','b','c');
$data = array('one','two','three',$inner);
printToFlash($data);
I get these results (printToFlash modified to say print "$key=$val<br>"😉:
0=one
1=two
2=three
0=a
1=b
2=c