Solution for “Fatal error: Maximum function nesting level of '100' reached, aborting!” in PHP?

Rather than going for a recursive function calls, work with a queue model to flatten the structure.

Rather than going for a recursive function calls, work with a queue model to flatten the structure. $queue = array('example.com/first/url'); while (count($queue)) { $url = array_shift($queue); $queue = array_merge($queue, find_urls($url)); } function find_urls($url) { $urls = array(); // Some logic filling the variable return $urls; } There are different ways to handle it. You can keep track of more information if you need some insight about the origin or paths traversed.

There are also distributed queues that can work off a similar model.

With SPL you do not need to reinvent the queue: php.net/manual/en/class.splqueue. Php – Francesco Dec 28 '11 at 13:40 SPL Queue might provide a bit more speed, but I like sticking to arrays for most simple tasks. Push/pop/shift/unshift are all provided.

– Louis-Philippe Huberdeau Dec 28 '11 at 15:30.

You could convert your recursive code into an iterative code, which simulates the recursion. This means that you have to push the current status (url, document, position in document etc. ) into an array, when you reach a link, and pop it out of the array, when this link has finished.

You could try to wiggle down the nesting by implementing parallel workers (like in cluster computing) instead of increasing the number of nesting function calls. For example: you define a limited number of slots (eg. 100) and monitor the number of "workers" assigned to each/some of them.

If any slots become free, you put the waiting workers "in them".

A simple solution solved my problem. I just commented the: "zend_extension = "d:/wamp/bin/php/php5.3.8/zend_ext/php_xdebug-2.1.2-5.3-vc9. Dll" in php.

Ini file. This extension was limiting the stack to 100 so I disabled it. The recursive function is now working as anticipated.

1 So, eventually it was the XDebug extension after all... Good to know. In two days you can accept your own answer as accepted answer, if you want (and have a look at your previous questions, most miss an accepted answer). – Abel Dec 29 '11 at 14:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions