during my quest for some basic php knowledge , I tried to do a simple function to read files and dirs that will not use recursive iterators. (more of an exercise but actually needed for any php<5.3 servers)

the function works great - but when i tried to add a switch ($output) - it no longer lists all the files (for example, before adding the switch, it can see 61 files in 4 folders (3+root) but with the added switch it can only see 47 (only root) .
am I doing something wrong here ? why does the switch statement break the faux "recursive-nest" ??

Thanks - point in the right direction. it actually did not work at first , but it DID work when i removed the continue; from if(is_dir("$dir/$value")) {$result2[]="$dir/$value"; continue;} // array dirs .. - would be nice to understand why ..
–
Obmerk KronenNov 19 '12 at 23:00

1

Because with the continues the recursion is never executed - one of the continues will always be triggered and skip over it. If it's a regular file the upper one and if it's a directory the lower one (which you must remove to make it work).
–
AndreKRNov 19 '12 at 23:07

BTW: For learning purposes I strongly recommend adding error_reporting(E_ALL); as very first line of your script and re-run (first, without fixing anything), because you should have seen a warning as 2nd function parameter is not optional. You got signature