Pyh.conf’25: a new PHP conference for the Russian-speaking community

Voting

: one plus two?
(Example: nine)

The Note You're Voting On

tibard at gmail dot com
20 years ago
use this function to get all files inside a directory (including subdirectories)

<?php
function scan_Dir($dir) {
$arrfiles = array();
if (
is_dir($dir)) {
if (
$handle = opendir($dir)) {
chdir($dir);
while (
false !== ($file = readdir($handle))) {
if (
$file != "." && $file != "..") {
if (
is_dir($file)) {
$arr = scan_Dir($file);
foreach (
$arr as $value) {
$arrfiles[] = $dir."/".$value;
}
} else {
$arrfiles[] = $dir."/".$file;
}
}
}
chdir("../");
}
closedir($handle);
}
return
$arrfiles;
}

?>

<< Back to user notes page

To Top