$array = [];
$dir = realpath('.'); // current directory
$fileSPLObjects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST);
foreach($fileSPLObjects as $fullFileName => $fileSPLObject) {
if ($fileSPLObject->isFile()) {
$info = new SplFileInfo($fullFileName);
if ($info->getExtension() === 'txt') {
#$array[] = $fullFileName; // add file in array
// Convert here
}
}
}
#echo '<pre>' . print_r($array, true); // dump files