Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.29 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to get the newest file in a directory in php
  2. $myFile = "data/FrontlineSMS_Message_Export_20120721.csv";  //The name of the CSV file
  3. $fh = fopen($myFile, 'r');                             //Open the file
  4.        
  5. $files = scandir('data', SCANDIR_SORT_DESCENDING);
  6. $newest_file = $files[0];