here is my path
c:CustomersNCRLas Piñas
and im trying to get all the csv files.
I did the code from here (see top answer) php glob – scan in subfolders for a file
and also did a mixed recursive and glob
JavaScript
x
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
$html = "";
foreach ($iterator as $folder) {
if ($folder->isDir()) {
$all_files = glob($folder->getRealpath() . "/*.csv");
foreach ($all_files as $filename) {
$html .= $filename . PHP_EOL;
}
}
}
echo $html;
and still cant read the csv inside this folder
Advertisement
Answer
so far this is what i came of
JavaScript
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
$csvs = [];
foreach ($iterator as $folder) {
if (!$folder->isDir()) {
$ext = pathinfo($folder->getRealpath(), PATHINFO_EXTENSION);
if (strtolower($ext) == 'csv') {
$csvs[] = $folder->getRealpath();
}
}
}