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, Quote Link to comment 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); Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.