简体   繁体   English

如何根据php中的文件名打开特定文件?

[英]How to open a specific file based on filename in php?

I need to open an HTML file which is inside nested folders.我需要打开嵌套文件夹内的 HTML 文件。

for example:例如:

*USERDATA\\FILES* Inside FILES- 8111,8114,8333,8585 (these are the folder names inside FILES) *USERDATA\\FILES* Inside FILES- 8111,8114,8333,8585(这些是 FILES 内的文件夹名称)

I should pick up the folder 8585我应该拿起文件夹 8585

Inside this FILES folder, I have 1 to 4 folders, the folder names will be in number.在这个 FILES 文件夹中,我有 1 到 4 个文件夹,文件夹名称将是数字。 I should pick up the folder which has the maximum number.我应该拿起最大数量的文件夹。 How to do that?怎么做?

note: since it is sorted, the file with the maximum number will be at last.注意:由于已排序,因此编号最大的文件将排在最后。

Use scandir function and sort desc folder name.使用 scandir 函数并排序 desc 文件夹名称。

$files2 = scandir($dir, 1); 

output :输出 :

Array
(
    [0] => somedir
    [1] => foo.txt
    [2] => bar.php
    [3] => ..
    [4] => .
)

PHP::scandir PHP::扫描目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM