php find file with highest value in its filename

acolyte

New Member
Consider this file structure:\[code\]/folder/locaux-S04_3.html/folder/blurb.txt/folder/locaux-S04_2.html/folder/locaux-S05_1.html/folder/tarata.02.jpg/folder/locaux-S04_1.html/folder/dfdsf.pdf\[/code\]I need to retrieve the file which name contains the highest numeric value in a directory.In the above example, it is locaux-S05_1.htmlI came up with glob() as an efficient way to only get the locaux-S*.html files but i'm stuck in the next step: finding the one which filename contains the highest value.\[code\]$files= glob(LOCAUX_FILE_PATH.'/locaux-S*.html');foreach($files as $key=> $value){ // loop through and get the value in the filename. Highest wins a trip to download land!$end = strrpos($value,'.');$len= strlen($value);$length = $len-$end;$str = substr($value,8,$length);// this gives me the meat, ex: 03_02. What next?}\[/code\]Any pointer would be very appreciated.
 
Back
Top