Php glob () does not return all files

I searched this site and found a very useful piece of code that I could use.

  $counter = 0; 
     foreach (glob("images/gallery/photo_gallery/resized/*.jpg") as $pathToThumb)
    {
        $filename = basename($pathToThumb);
        $pathToLarge = 'images/gallery/photo_gallery/' . $filename;
        echo ('<a href="'.$pathToLarge.'"><img src="'.$pathToThumb.'" /></a>');
        $counter++;
    }

But for some reason this will only return the first 30 images in my directory. (there are 81) Can anyone think why this is happening?

Thank.

+3
source share
2 answers

As I said above

$path = 'images/gallery/photo_gallery/resized/*';

will be sufficient. or, if you stubbornly want only jpg only,

$path = 'images/gallery/photo_gallery/resized/*.[Jj][Pg][Gg]';

as indicated in the manual

+1
source

Thank you all for your input.

Here's the extension of the answers - CASE-SENSITIVE when used in glob () (something I didn't know about)

30 .jpg, .JPG

, , glob("imagesPath/*.jpg") .

:)

, - .:)

+1

Source: https://habr.com/ru/post/1762045/


All Articles