PHP simple traversal rename

巴扎黑
Release: 2016-11-24 10:34:45
Original
1014 people have browsed it

Copy after login

1) How to count how many files there are in this directory
2) How to count how many php files there are in this directory
3) How to count how many non-txt files there are in this directory
$arr = scandir($ dir);
$all = count($arr)-2;//The total number of all files except ./ and ../
$php = count(preg_grep("/.php$/", $arr));
$ txt0 = $all - count(preg_grep("/.txt$/", $arr));
echo 'There are '.$all.' files, php files '.$php.', non-txt files'. $txt0.'piece';


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!