I am working on something that requires a function to run itself multiple times, and I'm curious just how much something like that may affect performance and speed.
I realize my initial statement is a little hard to follow, so I've provided an example.
PHP Code:
function checkArray($input) {
foreach($input as $key => $item) {
if(is_array($item)) {
echo "<dl><dt>".$key."</dt><dd>";
checkArray($item);
echo "</dd></dl>";
}
else {
echo "<dl><dt>".$key."</dt><dd>".$item."</dd></dl>";
}
}
}
Notice how, within that function, I am calling that same function again. It's possible, depending on how many dimensions an array may have, that multiple instances of that function could be running within each other (obviously we're going to have as many simultaneous instances of that function as we have dimensions in our multi-dimensional array, so if the array is nested 7 levels deep - God only knows why an array would be nested that deeply, but bear with me - then I'd be running that function inside of itself 7 times).
Again, I'm just curious how much something like that may effect performance. Unfortunately, I don't really have any good benchmarking tools to test it out with various dimensions of multi-dimensional arrays.