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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -