ftp or Mysql : sort files by date
I use it in a blog project : http://flamebaitpics.com
You can see my infinit scroll for li : https://coderwall.com/p/elea7q
if ($handle = opendir('./yourdos')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$array_chaine[] = array('nom' => $file, 'date'=>filemtime("./yourdos/$file"));
} //if
} //while
closedir($handle);
function cmp($a, $b)
{
if ($a['date'] == $b['date']) return 0;
return ($a['date'] > $b['date']) ? -1 : 1;
} //cmp
usort($array_chaine, "cmp");
while (list($key, $value) = each($array_chaine)) {
} //while
} //if
Written by Valentin Beuret
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Related Tags
#php
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#