duanlu1922 2014-06-10 02:22
浏览 45
已采纳

PHP - 用于查找文件的通配符?

I'm trying to make a PHP script to list everything in a directory but I want to exclude certain files ending in desc.txt as they'll take up too much space in the list. (They're there to provide descriptions to the actual script of each folder/file)

if ($file !== "." && $file !== ".." && $file !== "desc.txt"){

That hides the whole "../" button to go up a directory and stuff, but I really can't figure out how to make it hide files ending in desc.txt. I tried * and % and glob and all that other stuff but nothing has worked so I just have it there as desc.txt, any ideas?

  • 写回答

1条回答 默认 最新

  • doupafu6980 2014-06-10 02:25
    关注

    This should work.

    if ($file !== "." && $file !== ".." && substr($file, -8) !== "desc.txt"){ );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了