I'm trying to display the folder icon next to the folder, but it turns out that the icon is first displayed, and then everything else, I do not understand how to do it correctly.
<?php error_reporting(-1); header('Content-Type: text/html; char set=utf-8'); ini_set('display_errors', 'On'); //$dir = $_SERVER['DOCUMENT_ROOT'] . '/tmp'; $images = array('papka.jpg'); $dir = 'C:\OpenServer\domains\localhost\kurs\16\dzfm'; $files1 = scandir($dir); ?> <?php if(is_dir($_SERVER['DOCUMENT_ROOT'])){ foreach ($images as $img){ } ?> <img src="<?php echo $img; ?>"> <?php print_r($files1)?> <?php } ?> 
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $filename => $fileInfo){}- user207618