Last active
May 13, 2019 12:46
-
-
Save impshum/2036c9cc7ed7c2c57cc982d56bd3f849 to your computer and use it in GitHub Desktop.
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 | |
function gallery() | |
{ | |
$files = glob("images/*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}", GLOB_BRACE); | |
$sorted_files = array(); | |
foreach ($files as $file) { | |
$sorted_files[$file] = filemtime($file); | |
} | |
arsort($sorted_files); | |
foreach ($sorted_files as $image => $mtime) { | |
$d = date('d/m/Y', filemtime($image)); | |
echo "<h2>$d</h2>"; | |
echo "<br><img src='$image'><br>"; | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Gallery</title> | |
<style> | |
body { | |
margin: 0; | |
} | |
img { | |
width: 100%; | |
} | |
h2 { | |
font-size: 1.3em; | |
font-weight: 2em; | |
} | |
.container { | |
display: block; | |
width: 90%; | |
margin: 1em auto; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<?php gallery(); ?> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment