Page 1 of 1
recursive function problem
Posted: Mon Jun 01, 2009 3:48 pm
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?
Re: recursive function problem
Posted: Mon Jun 01, 2009 6:08 pm
by mikemike
Can you show us the code?
Re: recursive function problem
Posted: Mon Jun 01, 2009 8:33 pm
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
Re: recursive function problem
Posted: Mon Jun 01, 2009 9:42 pm
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.
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.