How do I count files in a folder but exclude index.php file from being counted as (PHP) -
this question has answer here:
- php code exclude index.php using glob 2 answers
i'm having issues on figuring out. how exclude files (eg: index.php) folder/ counted as. suggestions?
<?php $dir = "folder/"; $count = 0; $files = glob($dir . "*.{php}",glob_brace); if($files){$count = count($files);} echo'you have: '.$count.' files.'; ?>
i'm guessing need list these files @ point well, build new array of "approved" file names.
$dir = ""; $files = glob($dir . "*.{php}",glob_brace); $realfiles = array(); $ignore = array('index.php','otherfile.pdf'); // list of ignored file names foreach($files $f) { if(!in_array($f, $ignore)) { // file not in our ignore list $realfiles[]=$f; // add file name our realfiles array } } echo 'you have: '.count($realfiles).' files.'; print_r($realfiles);
Comments
Post a Comment