当前位置:网站首页>PHP counts the number of files in the specified folder
PHP counts the number of files in the specified folder
2022-04-23 04:52:00 【yizecellophp】
<?php
// Give me a folder , Return the number of all files in this folder
function ShuLiang($url)// Make a way , Give me a parameter
{
$sl=0;// Create a variable , Let him default to 0;
$arr = glob($url);// Save all the files under this path into an array ;
foreach ($arr as $v)// Circulation is convenient , Bar array $arr Assign to $v;
{
if(is_file($v))// Use a first if Judge whether the file in this folder is a file , It could be a folder ;
{
$sl++;// If it's a file , Quantity plus one ;
}
else
{
$sl+=ShuLiang($v."/*");// If it's a folder , Then call the function itself to get the number of files in this folder , This method is called recursion ;
}
}
return $sl;// When this method is finished , Returns a value $sl, This value is the number of all files in the path ;
}
echo ShuLiang("upload/*");// Use this method to check the number of all files in this path The file name in the root directory is enough ;
?>
版权声明
本文为[yizecellophp]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230445598802.html
边栏推荐
- Leetcode - > 1 sum of two numbers
- Raspberry pie + opencv + opencv -- face detection ------- environment construction
- PHP+MySQL 制作留言板
- Leetcode -- heuristic search
- Leetcode006 -- find the longest common prefix in the string array
- The last day of 2021 is the year of harvest.
- 【数据库】表的查看、修改和删除
- [WinUI3]編寫一個仿Explorer文件管理器
- Spark FAQ sorting - must see before interview
- MySQL -- execution process and principle of a statement
猜你喜欢
New terminal play method: script guidance independent of technology stack
Sword finger offer: the path with a certain value in the binary tree (backtracking)
Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
Introduction to raspberry pie 3B - system installation
【数据库】表的查看、修改和删除
【数据库】MySQL基本操作(基操~)
独立站运营 | FaceBook营销神器——聊天机器人ManyChat
C language: spoof games
Recommended scheme of national manufactured electronic components for intelligent electronic scales
Unity rawimage background seamlessly connected mobile
随机推荐
Record the blind injection script
Leetcode003 -- judge whether an integer is a palindrome number
leetcode006--查找字符串数组中的最长公共前缀
Installation and deployment of Flink and wordcount test
MySQL - data read / write separation, multi instance
Unity RawImage背景无缝连接移动
Field injection is not recommended using @ Autowired
Last day of 2017
Graduation project
General enumeration constant class
leetcode002--将有符号整数的数字部分反转
Case of using stream load to write data to Doris
CLion+OpenCV identify ID number - detect ID number
C list field sorting contains numbers and characters
PHP+MySQL 制作留言板
Innovative practice of short video content understanding and generation technology in meituan
Analysis of POM files
Introduction to raspberry pie 3B - system installation
Recommended scheme for national production of electronic components for wireless charging
What is a blocking queue? What is the implementation principle of blocking queue? How to use blocking queue to implement producer consumer model?