How to use ‘depth’?
On recursive methods, I usually add a $depth parameter: function my_function($depth = -1) { if ($depth === 0) { return array(); // or any other value insisting an empty or false result } // do something $result = array(); while ($some_condition) { $result = array_merge($result, my_function($depth – 1)); // decrease $depth value } // maybe … Read more