当前位置:网站首页>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
边栏推荐
- Better way to read configuration files than properties
- leetcode006--查找字符串数组中的最长公共前缀
- Leetcode008 -- implement strstr() function
- POI export message list (including pictures)
- Excel protects worksheets and workbooks from damage
- Jetpack -- lifecycle usage and source code analysis
- 【数据库】表的查看、修改和删除
- New terminal play method: script guidance independent of technology stack
- Code007 -- determine whether the string in parentheses matches
- Agile practice | agile indicators to improve group predictability
猜你喜欢
Innovation training (IV) preliminary preparation - server
redis数据类型有哪些
Unity RawImage背景无缝连接移动
Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
用LCR表完美测试无线充电系统中的线圈
Recommended scheme of national manufactured electronic components
Shanghai Hangxin technology sharing 𞓜 overview of safety characteristics of acm32 MCU
Unity rawimage background seamlessly connected mobile
Teach you how to build the ruoyi system by Tencent cloud
Learning Android II from scratch - activity
随机推荐
Gets all dates between two times
[winui3] write an imitation Explorer file manager
Innovation training (IX) integration
Sword finger offer: the median in the data stream (priority queue large top heap small top heap leetcode 295)
List remove an element
Other problems encountered in debugging fingerprints
Unity攝像頭跟隨鼠標旋轉
CLion+OpenCV identify ID number - detect ID number
Simply drag objects to the item bar
Agile practice | agile indicators to improve group predictability
用LCR表完美测试无线充电系统中的线圈
Leetcode006 -- find the longest common prefix in the string array
leetcode004--罗马数字转整数
Leetcode004 -- Roman numeral to integer
Use model load_ state_ Attributeerror appears when dict(): 'STR' object has no attribute 'copy‘
Open the past and let's start over.
redis数据类型有哪些
What is the meaning of load balancing
Innovation training (VI) routing
Record the ThreadPoolExecutor main thread waiting for sub threads