I have found plenty of examples of recursive functions to list directory contents, but I'm trying to do something a bit different.
I want to recursively walk a directory tree looking for something (it could be anything, such as a file with a particular file date, but let's just say I want to find a file named "happy.hhh"...) - and the catch is I want to terminate the function when I find what I'm looking for. There is no need to query 900 files if the second file matches my test, right?
So I have got all this to work so far, but the problem is how to exit the entire function. "Break" only exists the current "For" or "Foreach" loop and if the function is several levels deep, it simply picks up searching one level up.
If I use "return", same thing occurs.
If I use "exit" or "die", it works perfect as long as I'm only querying a single root directory since it stops the whole script. But I'm calling this function from other code and it stops this other code....
Hopefully someone has done something like this and could share. I'm sure there is a simple solution....
Thanks.