Created
March 27, 2019 12:05
-
-
Save faisal-ibrahim/630241578d446a280c8c31e3cac5cd52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Function for recursive directory file list search as an array. | |
| * | |
| * @param mixed $dir Main Directory Path. | |
| * | |
| * @return array | |
| */ | |
| function listFolderFiles($dir) | |
| { | |
| $fileInfo = scandir($dir); | |
| $allFileLists = []; | |
| foreach ($fileInfo as $folder) { | |
| if ($folder !== '.' && $folder !== '..') { | |
| if (is_dir($dir . DIRECTORY_SEPARATOR . $folder) === true) { | |
| $allFileLists[$folder] = listFolderFiles($dir . DIRECTORY_SEPARATOR . $folder); | |
| } else { | |
| $allFileLists[$folder] = $folder; | |
| } | |
| } | |
| } | |
| return $allFileLists; | |
| }//end listFolderFiles() | |
| $dir = listFolderFiles('your searching directory path ex:-F:\xampp\htdocs\abc'); | |
| echo '<pre>'; | |
| print_r($dir); | |
| echo '</pre>' | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment