Aristona
Aristona

Reputation: 9341

Using glob function to include different image parameters

$pictures = glob(path('public') . 'uploads/galleries/' . $dir_name . '/' . '*.jpg');

Right now it only retrieves .jpg files from a directory. However, I want it to be retrieving .JPG, .png, .PNG or others too.

I wonder if *.jpg can be used like; *.jpg|*.JPG|*.png|*.PNG or if I can attach a regex which basically does the same thing.

If glob() doesn't support such use, what would you suggest for this task?

Upvotes: 0

Views: 49

Answers (1)

Joseph Silber
Joseph Silber

Reputation: 219930

Use curly braces:

'*.{jpg,JPG,png,PNG}'

Upvotes: 2

Related Questions