Cant process subdirs named with numbers??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mjstenberg@hotmail.com

    Cant process subdirs named with numbers??

    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($dir Path) {


    chdir($dirPath) ;
    $dirPointer = opendir(".");
    while (($file = readdir($dirPoi nter)) != false) {
    if ($file == "." || $file == "..")
    continue; // skip current and upper
    directories
    if (filetype($file ) == "dir") {
    echo $file ."\n";
    readSubdir($fil e);
    } else {
    // echo "file is $file\n";
    } // else
    } // while
    closedir($dirPo inter);
    chdir("..");

    }

    Thanks

  • Hendri Kurniawan

    #2
    Re: Cant process subdirs named with numbers??

    mjstenberg@hotm ail.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($dir Path) {
    >
    >
    chdir($dirPath) ;
    $dirPointer = opendir(".");
    while (($file = readdir($dirPoi nter)) != false) {
    if ($file == "." || $file == "..")
    continue; // skip current and upper
    directories
    if (filetype($file ) == "dir") {
    echo $file ."\n";
    readSubdir($fil e);
    } else {
    // echo "file is $file\n";
    } // else
    } // while
    closedir($dirPo inter);
    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

    Comment

    Working...