Crazy Chuck
Crazy Chuck

Reputation: 555

scandir not working properly php

Does any one know how to scan directory recursively in php ?

$fileslist = array();

function readRecursive($dirname) {
   global $fileslist;
   $dir = scandir($dirname);

    foreach ($dir as $f) {
      if($f != "." && $f != ".." && $f != ".DS_Store") {
         if(is_dir($dirname.DIRECTORY_SEPARATOR.$f)) {
            $dname = $dirname.DIRECTORY_SEPARATOR.$f;
            readRecursive($dname);
         } else {
            $fileslist[] = $dirname.DIRECTORY_SEPARATOR.$f;
         }
      }
   }
}

following code doesn't work any idea Thanks in advance

Upvotes: 0

Views: 497

Answers (1)

Jerald
Jerald

Reputation: 345

First check it your php version. this function is available only above php 5.0

Upvotes: 2

Related Questions