当前位置:网站首页>PHP get the file list and folder list under the folder
PHP get the file list and folder list under the folder
2022-07-03 11:59:00 【BlizzardWu】
/** * Get file list * @param string $dir Absolute path */
function getDir($dir) {
$dirArray[] = NULL;
if (false != ($handle = opendir( $dir ))) {
$i=0;
while ( false !== ($file = readdir( $handle )) ) {
// Get rid of "“.”、“..” And the belt “.xxx” Postfix file
if ($file != "." && $file != ".."&&!strpos($file,".")) {
$dirArray[$i] = $file;
$i++;
}
}
// Closing handle
closedir ($handle);
}
return $dirArray;
}
// Get file list
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++;
}
}
// Closing handle
closedir ($handle);
}
return $fileArray;
}
边栏推荐
猜你喜欢
cgroup简介
OPenGL 基本知识(根据自己理解整理)
rxjs Observable filter Operator 的实现原理介绍
Extrapolated scatter data
laravel 时区问题timezone
STL Tutorial 9 deep copy and shallow copy of container elements
ftp登录时,报错“530 Login incorrect.Login failed”
VS2015的下载地址和安装教程
AOSP ~ NTP (Network Time Protocol)
[learning notes] DP status and transfer
随机推荐
MySQL union和union all区别
并发编程-单例
The excel table is transferred to word, and the table does not exceed the edge paper range
OpenGL 着色器使用
《剑指offer 04》二维数组查找
R语言使用data.table包进行数据聚合统计计算滑动窗口统计值(Window Statistics)、计算滑动分组中位数(median)并合并生成的统计数据到原数据集中
Mysql根据时间搜索常用方法整理
Groovy test class and JUnit test
R语言使用aggregate函数计算dataframe数据分组聚合的均值(sum)、不设置na.rm计算的结果、如果分组中包含缺失值NA则计算结果也为NA
解决msvcp120d.dll和msvcr120d.dll缺失
Momentum of vulnhub
Ripper of vulnhub
Yintai department store ignites the city's "night economy"
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据、在折线移动方向添加数据点
量化计算调研
vulnhub之Ripper
2022年中南大学夏令营面试经验
Vulnhub geminiinc V2
Visual studio 2022 downloading and configuring opencv4.5.5
Hongmeng third training (project training)