On my website I want to display a grid with images and their names to the gallery. Through html, displaying 600+ images is somehow wrong, but through php images is output. But how to display their names under them?
<?php $directory = "../img"; $allowed_types=array("jpg", "png", "gif"); $file_parts = array(); $ext=""; $title=""; $i=0; $dir_handle = @opendir($directory) or die("Ошибка при открытии папки !!!"); while ($file = readdir($dir_handle)) { if($file=="." || $file == "..") continue; $file_name = basename($directory,".png"); $file_parts = explode(".",$file); $ext = strtolower(array_pop($file_parts)); if(in_array($ext,$allowed_types)) { echo '<img src="'.$directory.'/'.$file.'" class="pimg" title="'.$file.'" /><br><p>'+$file_name+'</p>'; $i++; } } closedir($dir_handle); ?>
$file- Let's say Pie