PHP

HOW TO LIST FILES & FOLDERS IN PHP

$contents = scandir("FOLDER"); print_r($contents);

SCAN DIRECTORY

01

GET ALL PHP + TEXT FILES $scripts = glob("FOLDER/*.{php,txt}", GLOB_BRACE); print_r($scripts);

GLOB PATTERN

02

GET FOLDERS ONLY $folders = glob("FOLDER/*", GLOB_ONLYDIR); print_r($folders);

$target = "FOLDER"; if ($fh = opendir($target)) {   while (($entry = readdir($fh))   !== false) {     if ($entry!="." && $entry!="..")      { echo $entry; }   }   closedir($fh); }

OPEN DIRECTORY

03