Why is the glob function not displaying all JPG files as expected?

The issue may be due to case sensitivity in file extensions. The glob function is case-sensitive by default, so if the file extensions are in uppercase (e.g., JPG), they may not be matched. To fix this, you can use the GLOB_BRACE flag in the glob function to match both uppercase and lowercase file extensions.

$files = glob('path/to/files/*.{jpg,JPG}', GLOB_BRACE);
foreach ($files as $file) {
    echo $file . "<br>";
}