Created
April 7, 2020 14:48
-
-
Save eurowebpage/bdf240bb8ddcbfced99e18bd4c3d126a to your computer and use it in GitHub Desktop.
afficher-la-derniere-images-mise-a-jour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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