home
search
help
profile
liking the experience? our app is even better
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now  
showing results for file order by date added php
1<?php
2// get current directory path
3$dirpath = getcwd();
4// set file pattern
5$dirpath .= "\*.jpg";
6// copy filenames to array
7$files = array();
8$files = glob($dirpath);
9
10// sort files by last modified date
11usort($files, function($x, $y) {
12    return filemtime($x) < filemtime($y);
13});
14
15foreach($files as $item){
16    echo basename($item) . " => Last Modified On " . @date('F d, Y, H:i:s', filemtime($item)) . "<br/>";
17}
18?>
upvote
downvote
source