douhuang2673 2017-07-11 08:52
浏览 46
已采纳

两个数字之间的PHP shell_exec命令

I have this list of files and I need to get the files between two dates like this command shell in PHP:

all_doc_test_2017-07-01.dog
all_doc_test_2017-07-02.dog
all_doc_test_2017-07-03.dog
all_doc_test_2017-07-04.dog
all_doc_test_2017-07-05.dog
all_doc_test_2017-07-06.dog
all_doc_test_2017-07-07.dog
all_doc_test_2017-07-08.dog
all2_doc_test_2017-07-07.dog
all3_doc_test_2017-07-07.dog
all4_doc_test_2017-07-07.dog

I use this command to get one date:

shell_exec("ls -d /home/doc/*07.dog ");

so I get like this :

all_doc_test_2017-07-07.dog
all2_doc_test_2017-07-07.dog
all3_doc_test_2017-07-07.dog
all4_doc_test_2017-07-07.dog

I need a command to get the files between two numbers like this:

ls -d /home/doc/*01.dog  && ls -d /home/doc/*06.dog

and get this:

all_doc_test_2017-07-01.dog
all_doc_test_2017-07-02.dog
all_doc_test_2017-07-03.dog
all_doc_test_2017-07-04.dog
all_doc_test_2017-07-05.dog
all_doc_test_2017-07-06.dog
  • 写回答

1条回答 默认 最新

  • doucepei5298 2017-07-11 09:13
    关注

    PHP's glob() could handle that:

    $files = glob('./path/*07-0[1-6].dog');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序