duanquanhan2333 2013-01-20 16:33
浏览 37
已采纳

php计算来自多个文件夹和echo total的文件

I have a php code that will display the amount of files that i have in a folder.

Code: This will echo this on my page, "There are a total of 119 Articles"

$directory = "../health/";
if (glob($directory . "*.php") != false) /* change php to the file you require either html php jpg png. */ {
    $filecount = count(glob($directory . "*.php")); /* change php to the file you require either html php jpg png. */
    echo "<p>There are a total of";
    echo " $filecount ";
    echo "Articles</p>";
} else {
    echo 0;
}

Question:

I am wanting to count the files from 27 or more folders and echo the total amount of files.

Is there away i can add a list of folders to open such as:

$directory = "../health/","../food/","../sport/";

then it will count all the files and display the total "There are a total of 394 Articles"

Thanks

  • 写回答

5条回答 默认 最新

  • dougan1884 2013-01-20 16:41
    关注

    Yes you can:

    glob('../{health,food,sport}/*.php', GLOB_BRACE);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法