Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eurowebpage/6676610ecd5bf72b4ec03f3d7a857f5d to your computer and use it in GitHub Desktop.
Save eurowebpage/6676610ecd5bf72b4ec03f3d7a857f5d to your computer and use it in GitHub Desktop.
afficher-toutes-les-images-choix-extension-et-nom
<?php
//$files = glob("images/*.*");
$files = glob("img/*.*");
for ($i=0; $i<count($files); $i++)
{
$image = $files[$i];
$supported_file = array(
'gif',
'jpg',
'jpeg',
'png'
);
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
if (in_array($ext, $supported_file)) {
echo basename($image)."<br />"; // show only image name if you want to show full path then use this code // echo $image."<br />";
echo '<img src="'.$image.'" class="img-fluid" />';
} else {
continue;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment