[英]Implement date range pattern in PHP Glob pattern
I have to search directory names in PHP .我必须在PHP 中搜索目录名称。 I have a date range and the folder names contains the date on which they were created.
我有一个日期范围,文件夹名称包含它们的创建日期。 So I need to implement a date range pattern in glob function.
所以我需要在 glob 函数中实现一个日期范围模式。
Edit : Like I have to get the directories which were created between 10/11/2016
to 12/11/2016
.编辑:就像我必须获取在
10/11/2016
到12/11/2016
之间创建的目录。 The directory name is saved like H1346579_20161110123456
So, here the date is written in 20161110
.目录名称保存为
H1346579_20161110123456
所以,这里的日期写在20161110
。 I have to search this pattern in directory names.我必须在目录名称中搜索此模式。
Change 20161110
20161111
as disired.将
20161110
20161111
更改为20161110
20161111
。
foreach(glob('you_dir/*', GLOB_ONLYDIR) as $mydir)
{
if (preg_match('/20161110|20161111/i', $mydir)) {
$array_dirs[] = $mydir;
echo "<br> ";
echo $mydir;
}}
or in case you want an array print_r($array_dirs);
或者如果你想要一个数组
print_r($array_dirs);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.