Hello:
I am attempting to write an array diagnostic tool, to display the contents of an array, be it 1-dimensional, or N-dimensional.
Im using a function that calls itself again if the current value in the foreach loop is an array. Is there a way I can count how 'deep' or how many times the function has been called from within itself.. like how many function calls are stacked on one another?
The end goal is to echo the output to HTML and I want to put N number of spaces in front of the output depending on hwo deep it is, so that i can read the output.
Here is what i have so far.
function arydig($aryArray){
if (is_array($aryArray)){
foreach ($aryArray as $key => $value){
if (!is_array($value)){
print "[".$key."]: ".$value."<br />\n";
} else {
print "[".$key."]<br />\n";
arydig($value, ++$Depth);
}
}
}
}