david212 Posted February 25, 2009 Share Posted February 25, 2009 I need to count how many .txt files are in my folder, i created this code but it doesn't work. Can anyone help me? <?php $txtfils = array(); $f = opendir("fold"); while(($txtfils[]=readdir($f))); $s = sizeof($txtfils); $abc=0; for($i = 0;$i<$s;$i++){ if($txtfils[$i]==".txt"){ $abc++; } echo($abc); } ?> Thankx Link to comment https://forums.phpfreaks.com/topic/146877-solved-need-help-with-functions/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 25, 2009 Share Posted February 25, 2009 $files = glob('fold/*.txt'); echo count($files); Link to comment https://forums.phpfreaks.com/topic/146877-solved-need-help-with-functions/#findComment-771157 Share on other sites More sharing options...
david212 Posted February 26, 2009 Author Share Posted February 26, 2009 Thank you Link to comment https://forums.phpfreaks.com/topic/146877-solved-need-help-with-functions/#findComment-771641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.