sfullman;10993131 wrote:That means that arrays and variables I depend on using outside the function are no longer visible.
Why aren't they? Why can't you just pass them in as parameters?
If you really want to write obfuscated, messy code (hey, you shot down OOP, so why not shoot down other sensible concepts? 😉), then why encapsulate the processing code inside of a function at all?
sfullman;10993131 wrote:So the question is, how can I have the convenience of a recursive function but have the function make itself permeable to all variables as if it was not there?
Well, one neat and clean solution would be an OOP approach (I don't consider offering the best advice a "lecture", so I assume your third paragraph above doesn't apply?).
Next, you could simply pass whatever variables you need into the function as parameters (by reference, if you want to alter those variables' values as well).
Finally, if all else fails, you could just (ab)use the $GLOBALS superglobal array, though at that point I say you might as well go with my suggestion above (which I wasn't seriously suggesting at all, mind you!) and just get rid of the function encapsulation altogether.
sfullman;10993131 wrote:And without having to declare global $this, global $that, global $whatever - another housekeeping task to keep up with.
And not to mention the fact that if those global variables ever change names or are re-used elsewhere, your function's dependency on them won't be very apparent and you risk breaking it without ever having even touched it. But then again, that's what function parameters (or OOP!) are for.