Thanks for that Weedpacket, I think we are getting somewhere now.
My local Apache server still crashes when I run the function, but I have added a limit to my function, so it now looks like this:
$i = 0;
function print_recurse(&$array){
foreach ($array as $element) {
if($i < 7){
if(is_array($element) || (is_object($element) && !empty($element->children))){
// If there are more levels to recurse
print_recurse($element);
} else {
// Element has no children, so no more levels to recurse
echo "<li><a href=\"" . URIComponent::publicURL($element->nodeid) . "\">" . $element->title . "</a></li>";
}
$i++;
}
}
}
When I limit my function to 7 elements, it doesn't crash my server. When I set it to 8 elements, it crashes it. So I have narrowed the problem down to this particular element:
[permissions] => IndependentPermissionsModel Object
(
[number:private] => 2
)
There are two interesting things about this object:
- It is the first object in the array to have a private property
- It is the first object in the array to have no children
Which one of these things could be causing my function to fail, and how can I work around it?