[英]PHP - Find latest file based on filename pattern
I have a bunch of gamers data. 我有一堆玩家数据。 The data is stored as json with filename pattern as
gamerid_date_time_seed.json
. 数据存储为json,文件名模式为
gamerid_date_time_seed.json
。 Eg below: 例如:
8841-2018-05-03-09-56-14-2118-data.json
8841-2018-05-03-10-50-22-1568-data.json
8841-2018-05-04-04-36-51-6081-data.json
8841-2018-05-04-06-56-50-1100-data.json
In the first filename for example, 2018-05-03-09-56-14
is the year-month-date-hour-min-sec
format. 例如,在第一个文件名中,
2018-05-03-09-56-14
是year-month-date-hour-min-sec
格式。 8841
is the gamer id and the last 4 digits, 2118
in this case is a seed value that can be ignored. 8841
是玩家ID,最后4位数字,在这种情况下, 2118
是可以忽略的种子值。
How can I parse this so that I get only the latest data file of a gamer? 我该如何解析,以便仅获得玩家的最新数据文件? (In this case 8841-2018-05-04-06-56-50-1100-data.json) The issue is that sometimes a gamer might have multiple files but for same day.
(在这种情况下为8841-2018-05-04-06-56-50-1100-data.json)问题是有时游戏玩家可能有多个文件但同一天。
I am not very good with regular expressions and stuff so I would really appreciate some help here. 我对正则表达式和其他东西不太满意,因此在此我将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.