homepage Welcome to WebmasterWorld Guest from 54.197.110.151
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
counting file with filename containing
ahmed24

5+ Year Member



 
Msg#: 4103804 posted 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

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4103804 posted 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;
?>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved