note 127967 added to function.glob
| From: | DavidSpector at main dot php dot net | Date: | Mon, 28 Nov 2022 13:45:49 +0000 |
| Subject: | note 127967 added to function.glob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219923@lists.php.net to get a copy of this message | ||
Here is basic PHP code to do a recursive scan of an entire directory tree, allowing you to do
processing when reaching each directory and file:
// Do a recursive scan of an entire directory tree,
// starting with the current working directory
// using relative filepaths
// Includes files starting with '.'
// Minimally tested on Windows and Linux
Scan('.');
function Scan($dir)
{
// Add code for each directory $dir here
$subdirs=glob($dir.'/{.[!.],}*',GLOB_BRACE);
foreach ($subdirs as $file)
{
if (is_file($file))
{
// Add code for each file $file here
}
else if (substr($file,0,1)!='./.')
Scan($file);
}
} // Scan
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.159.161 (proxied: 98.2.238.89)
----
Manual Page -- https://php.net/manual/en/function.glob.php
Edit -- https://main.php.net/note/edit/127967
Del: integrated -- https://main.php.net/note/delete/127967/integrated
Del: useless -- https://main.php.net/note/delete/127967/useless
Del: bad code -- https://main.php.net/note/delete/127967/bad+code
Del: spam -- https://main.php.net/note/delete/127967/spam
Del: non-english -- https://main.php.net/note/delete/127967/non-english
Del: in docs -- https://main.php.net/note/delete/127967/in+docs
Del: other reasons-- https://main.php.net/note/delete/127967
Reject -- https://main.php.net/note/reject/127967
Search -- https://main.php.net/manage/user-notes.php