im looking a better way to count how many images are in a folder, im using this script:
$direccion = "/var/www/XXXX/XXX/XXX/httpdocs/images/helo/";
if (glob($direccion . "*.jpg") != false)
{
$filecount1 = count(glob($direccion . "*.jpg"));
}
else
{
$filecount1 = 0;
}
if (glob($direccion . "*.jpeg") != false)
{
$filecount2 = count(glob($direccion . "*.jpeg"));
}
else
{
$filecount2 = 0;
}
if (glob($direccion . "*.JPG") != false)
{
$filecount3 = count(glob($direccion . "*.JPG"));
}
else
{
$filecount3 = 0;
}
if (glob($direccion . "*.JPEG") != false)
{
$filecount4 = count(glob($direccion . "*.JPEG"));
}
else
{
$filecount4 = 0;
}
$conteodefotos = $filecount4 + $filecount3 + $filecount2 + $filecount1;
echo $conteodefotos;
But this will not count if the extension has mix capital letters, like "file.JpG"
Is there a simple and more eficient way to do this?