php遍历目录方法小结
作者:intergret 时间:2023-11-17 12:49:40
本文实例总结了php遍历目录方法。分享给大家供大家参考。具体如下:
1. 方法1
<?php
function myscandir($pathname){
foreach( glob($pathname) as $filename ){
if(is_dir($filename)){
myscandir($filename.'/*');
}else{
echo $filename.'<br/>';
}
}
}
myscandir('D:/wamp/www/exe1/*');
?>
2. 方法2
<?php
function myscandir($path){
$mydir=dir($path);
while($file=$mydir->read()){
$p=$path.'/'.$file;
if(($file!=".") AND ($file!="..")){
echo $p.'<br>';
}
if((is_dir($p)) AND ($file!=".") AND ($file!="..")){
myscandir($p);
}
}
}
myscandir(dirname(dirname(__FILE__)));
?>
希望本文所述对大家的php程序设计有所帮助。
标签:php,遍历,目录
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
基于python对B站收藏夹按照视频发布时间进行排序的问题
2022-01-02 11:11:31
深入了解Python枚举类型的相关知识
2022-08-02 06:15:40
Python爬虫框架Scrapy安装使用步骤
2022-02-23 13:49:09
PyQt5 PySide2 触摸测试功能的实现代码
2022-06-23 22:22:25
![](https://img.aspxhome.com/file/2023/3/86643_0s.png)
SQL Server系统函数介绍
2024-01-17 19:50:16
vue项目input标签checkbox,change和click绑定事件的区别说明
2024-05-21 10:29:27
![](https://img.aspxhome.com/file/2023/2/123932_0s.png)
在python里使用await关键字来等另外一个协程的实例
2021-03-01 19:10:16
python处理emoji表情(两个函数解决两者之间的联系)
2022-12-03 18:51:12
![](https://img.aspxhome.com/file/2023/3/101133_0s.jpg)
Python栈算法的实现与简单应用示例
2023-11-16 23:18:30
![](https://img.aspxhome.com/file/2023/2/105092_0s.png)
如何用Python做一个微信机器人自动拉群
2023-04-07 10:50:09
Python线程下使用锁的技巧分享
2023-10-03 06:05:42
React TypeScript 应用中便捷使用Redux Toolkit方法详解
2023-08-11 09:48:21
![](https://img.aspxhome.com/file/2023/6/55976_0s.jpg)
golang的HTTP基本认证机制实例详解
2024-04-26 17:28:39
Anaconda入门使用总结
2023-02-06 20:11:18
![](https://img.aspxhome.com/file/2023/9/107949_0s.png)
Python 中创建 PostgreSQL 数据库连接池
2024-01-19 22:33:37
ASP 根据用户权限判断显示的列标题
2011-03-29 11:01:00
PHP实现的杨辉三角求解算法分析
2023-11-19 13:52:29
![](https://img.aspxhome.com/file/2023/9/55679_0s.jpg)
python3.9之你应该知道的新特性详解
2021-09-01 12:13:42
Windows 2003服务器上传文件受限制的解决方法
2011-02-14 11:29:00
PHP延迟静态绑定的深入讲解
2024-06-05 15:42:51