当前位置:网站首页>php 获取文件夹下面的文件列表和文件夹列表
php 获取文件夹下面的文件列表和文件夹列表
2022-07-03 11:06:00 【BlizzardWu】
/** * 获取文件列表 * @param string $dir 绝对路径 */
function getDir($dir) {
$dirArray[] = NULL;
if (false != ($handle = opendir( $dir ))) {
$i=0;
while ( false !== ($file = readdir( $handle )) ) {
//去掉"“.”、“..”以及带“.xxx”后缀的文件
if ($file != "." && $file != ".."&&!strpos($file,".")) {
$dirArray[$i] = $file;
$i++;
}
}
//关闭句柄
closedir ($handle);
}
return $dirArray;
}
//获取文件列表
function getFile($dir) {
$fileArray[] = NULL;
if (false != ($handle = opendir ( $dir ))) {
$i=0;
while ( false !== ($file = readdir ( $handle )) ) {
if ($file != "." && $file != ".."&&strpos($file,".")) {
$fileArray[$i]['url'] = $dir.$file;
$fileArray[$i]['name'] = $file;
if($i==100){
break;
}
$i++;
}
}
//关闭句柄
closedir ($handle);
}
return $fileArray;
}
边栏推荐
猜你喜欢
Numpy np. Max and np Maximum implements the relu function
AI模型看看视频,就学会了玩《我的世界》:砍树、造箱子、制作石镐样样不差...
(数据库提权——Redis)Redis未授权访问漏洞总结
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
PHP server interacts with redis with a large number of close_ Wait analysis
Groovy test class and JUnit test
How to get started embedded future development direction of embedded
vulnhub之presidential
Understand go language context in one article
Qt OpenGL 纹理贴图
随机推荐
STL Tutorial 9 deep copy and shallow copy of container elements
Experience container in libvirt
Uniapp implementation Click to load more
Raven2 of vulnhub
R language uses the aggregate function to calculate the mean value (sum) of dataframe data grouping aggregation without setting na The result of RM calculation. If the group contains the missing value
2022 东北四省赛 VP记录/补题
Understand go language context in one article
R语言使用gridExtra包的grid.arrange函数将lattice包的多个可视化图像横向组合起来,ncol参数自定义组合图列数、nrow参数自定义组合图行数
Kibana - installation and configuration of kibana
cgroup简介
phpcms 提示信息页面跳转showmessage
R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
Vulnhub geminiinc V2
小鹏 P7 撞护栏安全气囊未弹出,官方回应称撞击力度未达到弹出要求
Concurrent programming - singleton
抓包整理外篇fiddler———— 会话栏与过滤器[二]
Qt OpenGL相机的使用
vulnhub之GeminiInc
Numpy np. Max and np Maximum implements the relu function
R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)