Skip to main content

Lendo arquivos de uma pasta com php

$pasta = __DIR__.'/pasta/processar';
$iterator = new DirectoryIterator($pasta);

foreach ( $iterator as $entry )
{
	if($entry->isFile ())
	{
		$file_extension = pathinfo($entry->getFilename(), PATHINFO_EXTENSION);
		if($file_extension=='log')
		{
			$arquivos[] = $entry->getPathname();
		}
	}
}