tags:

views:

33

answers:

2

Hello there.

I searched this site and found a very useful snippet of code that i've been able to 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?

Thanks.

A: 

Thanks to everyone for input.

Here's the answer - file extensions are CASE-SENSITIVE when used in glob() (something I was un-aware of)

30 of my files end in .jpg whilst the remaining files have been auto renamed through a resizing program to .JPG

So this means glob("imagesPath/*.jpg") only returned the lower-case matches.

Another lesson learnt :)

Hopefully this answer can help someone else too. :)

shane
A: 

As I have said above

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

would be enough. or, if you stubbornly wants only jpg only,

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

as manual suggests

Col. Shrapnel
$path = 'images/gallery/photo_gallery/resized/*.[Jj][Pg][Gg]';this does the trick for me. Thanks :)
shane