# PHP and Recursion

- Thread: https://externals.io/message/22009
- Original archive: https://news-web.php.net/php.internals/22009
- Started by Brian Moon on 2006-02-24T22:05:29+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22009 — Brian Moon — 2006-02-24T22:05:29+00:00

URL: https://externals.io/message/22009#22009

Hi guys,

I am working on script that will assemble data to create a page and have 
come to an interesting conclusion.  Its a perfect fit for recursion as 
part 1 of the doc will require additional parts and so on.

I wrote it at first with two loops.  The first loop gathered data and 
the second arranged the data.

For completeness sake, I rewrote it using recursion where I have a 
get_data() function that is called within itself if said data needs more 
data.

The results were quite suprising.  I get about a 80% increase in speed 
(using openload with 20 concurrents to test) using the recursion.  Now, 
at most, I will be recursing 4 or 5 levels deep.

Does PHP optimize recursion in such a way that this is expected or did I 
get lucky and I may hit a wall when I am not looking?

-- 
Brian Moon
dealnews.com
--------------
How to go broke saving money.
http://dealnews.com/
