I would like to count all characters in text files in certain path, so i've wrote the following code
<?PHP
$files = glob('my/files/path/*.txt', GLOB_BRACE);
foreach($files as $file) {
$str = file_get_contents($file) or dir("can not read file");
$numCharSpace = strlen($str);
echo "Counted " .$numCharSpace. " character(s).<br>";
}
?>
Let say, we have 4 files inside this path so it will print out the following
Counted 201 character(s).
Counted 99 character(s).
Counted 88 character(s).
Counted 112 character(s).
How can i get the total of all which should be 500 character(s)
so how to print out the count of all results which are inside foreach();
loop.