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. Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/ 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 Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870692 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 Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870694 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!!!!!!!!!!!!!!!!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870695 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? Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870697 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 Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870707 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 Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870714 Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 It is! Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870721 Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 Anyone? Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870730 Share on other sites More sharing options...
trq Posted July 8, 2009 Share Posted July 8, 2009 Anyone... what? Post your code! Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870743 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? Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870749 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/*.*")); Link to comment https://forums.phpfreaks.com/topic/165125-solved-tell-me-how-man/#findComment-870826 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.