PHP 按名称包含
我有一个 content
文件夹,其中充满了按以下方式命名的其他子目录:
id1_1
id1_2
id1_3
id2_1
id2_2
等等。每个文件夹都包含一个文件 template.php
。
文件夹的数量是动态的,因此我需要找到一种方法将从所有以 id_1_
开头的文件夹中导入所有 template.php
到我的 index.php< /代码> 文件。有什么简单的方法可以做到这一点吗?
I have a content
folder which is full of other sub-directories named in the following way:
id1_1
id1_2
id1_3
id2_1
id2_2
And so on. Each of these folders contains a file template.php
.
The number of folders is dynamic, so I need to find a way to import all the template.php
from all folders starting with id_1_
into my index.php
file. Is there any easy way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 glob() 函数:
You can use the glob() function:
可以使用递归函数+foreach+glob:
http://www.php.net/glob
You can use a recursive function + foreach + glob:
http://www.php.net/glob