Toggle navigation
Dashboard
Dashboard Tracker
Add / Edit My Forums
System Announcements
Discussion
Active Thread Feed
Top Threads Today
Top Threads This Week
Top Threads Library
Go!
View All
View All
Login
Logout
Home
Forums Index
Server Side
/
PHP Server Side Scripting
1:49 am Sep 21, 2026
This page requires javascript.
Forum Moderators:
coopster
Message Too Old, No Replies
counting file with filename containing
ahmed24
Msg#:4103806
3:31 pm on Mar 24, 2010
(gmt 0)
i have a folder called "datafolder" and i would like to see if there are files in there that begin with the name "2010-002" and if so how many files there are that begin with that convention.
can any advise me on how i can achieve this?
thanks
StoutFiles
Msg#:4103811
3:41 pm on Mar 24, 2010
(gmt 0)
Run this in the folder.
<?php
$count = 0;
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if(substr_count($file, '2010-002') >= 1)
{$count++;}
}
}
closedir($handle);
}
echo "Count: ".$count;
?>
Join The Conversation
Register
For Free! -
Become a
Pro Member
!
See forum categories
-
Enter the Forum
Moderators and Top Contributors
Moderator List
| Top Contributors:
This Week
,
This Month
,
Aug
,
Jul
,
Archive
,
Top 100 All Time
,
Top Voted Members
Hot Threads This Week
September 2026 Google Search Observations
AdSense Earnings and Observations - September 2026
An old fashioned desktop WYSIWIG HTML editor
Hit a new milestone today, 1 million requests.
Home
Forums Index
Server Side
/
PHP Server Side Scripting
1:49 am Sep 21, 2026