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/bdf240bb8ddcbfced99e18bd4c3d126a to your computer and use it in GitHub Desktop.
Save eurowebpage/bdf240bb8ddcbfced99e18bd4c3d126a to your computer and use it in GitHub Desktop.
afficher-la-derniere-images-mise-a-jour
<?php
$path = 'img/'; // nom du répertoire ou sont placés les images
$last_time = 0;
$last_image = '';
$dir = opendir($path); // ouverture du dossier
while($image = readdir($dir))
{
if (is_file($path.$image))
{
// selectionne la date de l'image
$date_file = filemtime($path.$image);
if ($date_file > $last_time)
{
$last_time = $date_file;
$last_image = $path.$image;
}
}
}
// Affiche la dernière image mise a jour
if ($last_image)
{
echo '<img src="' . $last_image . '" alt="dernier image à jour" class="img-fluid">';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment