JacobMarshall Posted July 8, 2009 Share Posted July 8, 2009 Can I have a script that tells you a number of how many files in a directory. Like, there are 324 files in the directory. Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 8, 2009 Share Posted July 8, 2009 A modified this... <?php if ($handle = opendir('/path/to/files')) { echo "Directory handle: $handle\n"; echo "Files:\n"; /* This is the correct way to loop over the directory. */ for($i=0;(false !== ($file = readdir($handle)));$i++) { } $filecount=$i; closedir($handle); } ?> use the php.net / google! http://us2.php.net/manual/en/function.readdir.php Quote Link to comment Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 Sorry, It just says http://jmarshall.uuuq.com/jhost/imageshosted.php Quote Link to comment Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 I just edited it and It works, Thanks!!!!!!!!!!!!!!!!!!!!!!! Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 8, 2009 Share Posted July 8, 2009 lol np. was it those echos i accidently left in? Quote Link to comment Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 Sorry, I tjought it was ok but it says "Resource id #2", but I want it to say e.g. "243" if there are 243 files in the directory Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 8, 2009 Share Posted July 8, 2009 try: <?php if ($handle = opendir('/path/to/files')) { echo "Directory handle: $handle\n"; echo "Files:\n"; $a=0; while (false !== ($file = readdir($handle))) { $a++; } closedir($handle); echo "$a files"; } ?> make sure the dir path is correct Quote Link to comment Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 It is! Quote Link to comment Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 Anyone? Quote Link to comment Share on other sites More sharing options...
trq Posted July 8, 2009 Share Posted July 8, 2009 Anyone... what? Post your code! Quote Link to comment Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 I didn't post those posts! The problem is solved! Why does it say I posted that? Quote Link to comment Share on other sites More sharing options...
Philip Posted July 8, 2009 Share Posted July 8, 2009 Or, as long as your OS supports it (most do) echo count(glob("path/to/dir/*.*")); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.