How do I count files in a folder but exclude index.php file from being counted as (PHP) -


this question has answer here:

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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -