recursive function problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

recursive function problem

Post by jazz090 »

im running a recursive function but its got a glitch in it that when i use return in the function it doesnt call it again. rest assured that the return and the re-call are in seperate if-else clauses so i dont think that the return is terminating the script before the function is re-called.any ideas?
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: recursive function problem

Post by mikemike »

Can you show us the code?
montana111
Forum Newbie
Posts: 6
Joined: Thu May 28, 2009 7:51 pm

Re: recursive function problem

Post by montana111 »

yeah if you could show us the code that would be helpful. in general tho i find that when im having trouble with something like this it is because i want to make a recursive function but i start it out iteratively and then its just a bad algorithm. idk tho, im new to php so post the code and maybe something will happen
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: recursive function problem

Post by s.dot »

Of course it won't call it again if you're returning something. When you return something that should be the end of the recursion. Don't return if you're not doing recursing. :-D

I think what you want to do is pass what you're currently returning to the function again as a parameter. But like the others have said, it is hard without seeing any code.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply