当前位置:网站首页>php怎么判断目录下有几个文件
php怎么判断目录下有几个文件
2022-08-07 09:03:00 【minihuabei】
php判断目录下有几个文件的方法:1、使用scandir()函数获取目录下的文件及文件夹名称,会返回一个包含有文件及文件夹名称的数组;2、使用“count(数组)-2”语句来获取目录下文件的数量。
在php中,可以利用scandir()和count()函数来判断目录下有几个文件。
示例:
有一个img目录,里面有8张图片文件
<?php
header("Content-type:text/html;charset=utf-8");
$dir = './img';
if(is_dir($dir)){
$arr = scandir($dir);
}
var_dump($arr);
$len=count($arr)-2;
echo "指定img目录上的文件数目:".$len;
?>

边栏推荐
- decentralized and centralized
- Addition, deletion, search and modification of doubly linked list
- redis的原理和源码-数据持久化方式AOF的介绍和源码解析
- Arthas 使用报错
- VisualVM工具的下载及插件安装
- 岛屿的最大面积
- 分散和集中
- In-depth analysis of Spark SQL illustrates the execution process and application scenarios of five Join strategies
- 当一个用户登录时,会引发哪些安全性的思考呢
- 关于在物联网公司实习这几天的收获
猜你喜欢

jenkins配置自动打包

Scala——While和do..While循环控制

window.requestAnimationFrame Web3D渲染帧率控制

pip3升级后报错f“pip[sys.version_info.major)“

左益豪:用代码创造一个新世界|OneFlow U

基于miniprogram-ci的微信小程序的CI以及接入钉钉通知

Unity 3D game general system settings page, custom key settings, background blur, image settings, brightness, contrast, saturation, volume adjustment, resolution windowing, frame rate vertical sync, a

redis的原理和源码-redis的六种数据类型基本介绍:string、hash、list、set、zset、stream

In-depth analysis of Spark SQL illustrates the execution process and application scenarios of five Join strategies

Addition, deletion, search and modification of doubly linked list
随机推荐
[Punctuality Atom STM32 Serial] Chapter 7 Understanding the HAL Library Excerpted from [Punctual Atom] MiniPro STM32H750 Development Guide_V1.1
The principle and source code of redis - transaction mechanism
DCDC电源方案设计踩坑
LVS+Keepalived高可用群集部署
架构师杂谈【摘抄】
The principle and source code of redis-server introduction and source code analysis (execution process of command request, server initialization process)
redis的原理和源码-redis的六种数据类型基本介绍:string、hash、list、set、zset、stream
redis的原理和源码-集群的原理和源码解析(上)
Redis principle and way of source data persistence RDB introduction and source code parsing
2022华数杯数学建模-在线文档
基于miniprogram-ci的微信小程序的CI以及接入钉钉通知
对动态表单编辑器指定dom绑定快捷键不生效,原来缺少了这个属性
Canvas image drawing (with zoom in, zoom out and drag functions)
Error f "pip[sys.version_info.major)" is reported after pip3 upgrade
(八)DDR_PHY架构及功能——(PUB组成、初始化及Training流程、Clock关系)
[Punctuality Atom STM32 Serial] Chapter 5 Introduction to STM32 Basics Excerpted from [Punctuality Atom] MiniPro STM32H750 Development Guide_V1.1
多路复用技术
pip3升级后报错f“pip[sys.version_info.major)“
window.requestAnimationFrame Web3D rendering frame rate control
The principle and source code of redis - three common problems of caching (cache penetration, cache breakdown, cache avalanche)