<?php
function rglob($pattern, $flags = 0, $path = '') {
if (!$path && ($dir = dirname($pattern)) != '.') {
if ($dir == '\\' || $dir == '/') $dir = '';
return rglob(basename($pattern), $flags, $dir . '/');
}
$paths = glob($path . '*', GLOB_ONLYDIR | GLOB_NOSORT);
$files = glob($path . $pattern, $flags);
foreach ($paths as $p) $files = array_merge($files, rglob($pattern, $flags, $p . '/'));
return $files;
}
$fileList = rglob("*", GLOB_MARK, '/etc/');
foreach($fileList as $index => $file) {
if($file[strlen($file) - 1] != "/")
{
echo "f: ".$file."\n";
} else echo "d: ".$file."\n";
}
preferences:
36.71 ms | 402 KiB | 5 Q