lopes_andre Posted December 20, 2010 Share Posted December 20, 2010 Hi, I have the following situation: Array ( [5] => GeoLiteCity_20090601.zip [6] => GeoLiteCity_20090701.zip [7] => GeoLiteCity_20090801.zip [8] => GeoLiteCity_20090901.zip [9] => GeoLiteCity_20091001.zip [10] => GeoLiteCity_20091101.zip [11] => GeoLiteCity_20091201.zip [12] => GeoLiteCity_20100101.zip [13] => GeoLiteCity_20100201.zip [14] => GeoLiteCity_20100301.zip [15] => GeoLiteCity_20100401.zip [16] => GeoLiteCity_20100501.zip [17] => GeoLiteCity_20100601.zip [18] => GeoLiteCity_20100701.zip [19] => GeoLiteCity_20100801.zip [20] => GeoLiteCity_20100901.zip [21] => GeoLiteCity_20101001.zip [22] => GeoLiteCity_20101101.zip [23] => GeoLiteCity_20101201.zip ) I have this array with filenames, the patern for the name of the file is NAME_DATE.zip I need to get from this array the most recent file(GeoLiteCity_20101201.zip). Which is the best way of doing this task? Give me some clues. Best Regards, Link to comment https://forums.phpfreaks.com/topic/222216-how-to-get-the-date-from-filenames/ Share on other sites More sharing options...
johnny86 Posted December 20, 2010 Share Posted December 20, 2010 If the last index of that array is always the latest file, you could just use: $latest = array_pop($files); Link to comment https://forums.phpfreaks.com/topic/222216-how-to-get-the-date-from-filenames/#findComment-1149561 Share on other sites More sharing options...
AbraCadaver Posted December 20, 2010 Share Posted December 20, 2010 http://us2.php.net/manual/en/function.sort.php Then http://us2.php.net/manual/en/function.end.php or http://us2.php.net/manual/en/function.reset.php Depending on how you sorted. Link to comment https://forums.phpfreaks.com/topic/222216-how-to-get-the-date-from-filenames/#findComment-1149594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.