<?php
// integer starts at 0 before counting
$i = 0;
$dir = '50/images/';
if ($handle = opendir($dir)) {
while (($file = readdir($handle)) !== false){
if (!in_array($file, array('.', '..')) && !is_dir($dir.$file))
$i++;
}
}
// prints out how many were in the directory
echo "$i items";
?>
if ($handle = opendir($dir)) {
$path = __DIR__ . '/50/images/';
if (!is_dir($path)) {
throw new \RuntimeException(sprintf('Incorrect path: %s', $path));
}
$foundFiles = array_diff(scandir($path), ['..', '.']);
// Warning, it could be folders to
echo count($foundFiles);