I need a solution for list folders and sub folders and all files inside that folders and sub-folders.
In snippet code I put a php code that has been write by Ray Pauser, and that code list a specific folder and give me the contain.
But if that folder contain more folders and sub folders, and that folders contain files inside?
I need to list like a tree, and in the end I need the output in this way (can be a array):
the order is not important.
What changes I have to do in the code in snippet code?
The best regards, JC
<?php // RAY_temp_joao.php
// WHAT DIRECTORY?
// the dir is the same where this script will run
$dir = "/";
// READ THE CURRENT WORKING DIRECTORY
if ($dh = opendir($dir))
while (($file = readdir($dh)) !== false)
echo "filename: $file : filetype: " . filetype($dir . DIRECTORY_SEPARATOR . $file) . PHP_EOL;