note 56379 deleted from function.scandir by cmb
| From: | cmb@php.net | Date: | Sun, 17 Nov 2019 09:04:19 +0000 |
| Subject: | note 56379 deleted from function.scandir by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213115@lists.php.net to get a copy of this message | ||
Note Submitter: Yassin Ezbakhe <yassin88 at gmail dot com>
----
<?php
/**********************************************
*
* PURPOSE: List files inside the specified path and its
* subdirectories
*
* array scandir_recursive (string dir)
*
* This function will return a multidimensional array
* that represents main folder's tree structure.
* Each folder has its own named array
*
**********************************************/
function scandir_recursive($directory)
{
$folderContents = array();
$directory = realpath($directory).DIRECTORY_SEPARATOR;
foreach (scandir($directory) as $folderItem)
{
if ($folderItem != "." AND $folderItem != "..")
{
if (is_dir($directory.$folderItem.DIRECTORY_SEPARATOR))
{
$folderContents[$folderItem] = scandir_recursive(
$directory.$folderItem."\\");
}
else
{
$folderContents[] = $folderItem;
}
}
}
return $folderContents;
}
?>