Posted by Hendri Kurniawan on 03/05/07 23:58
mjstenberg@hotmail.com wrote:
> Im using a batch process function but found PHP to behave very
> strangely: It only reads subdirs that have caharacters in their names.
> Im having subdirs with integer names (0, 1, 2, 3.. ) but this script
> does not read them at all?! Can someone tell me how to get around
> this?
> function readSubdir($dirPath) {
>
>
> chdir($dirPath);
> $dirPointer = opendir(".");
> while (($file = readdir($dirPointer)) != false) {
> if ($file == "." || $file == "..")
> continue; // skip current and upper
> directories
> if (filetype($file) == "dir") {
> echo $file ."\n";
> readSubdir($file);
> } else {
> // echo "file is $file\n";
> } // else
> } // while
> closedir($dirPointer);
> chdir("..");
>
> }
>
> Thanks
>
Works fine under my computer.
BTW there is a function called is_dir that checks whether or not
the string is a directory. IMHO better compatibility.
Hendri
Navigation:
[Reply to this message]
|