php foreach glob multiple extensions

foreach, glob, php

Solution

if(glob("images/*.{jpg,png,gif}", GLOB_BRACE))
{
  //create gallery
}

And that's about it :)

Problem

There has got to be a better way to write this: ``` <?php $imagecounter = "no"; foreach (glob("images/*.jpg") as $image) { $imagecounter = "yes"; } foreach (glob("images/*.png") as $image) { $imagecounter = "yes"; } foreach (glob("images/*.gif") as $image) { $imagecounter = "yes"; } if ($imagecounter == "yes"){Create gallery}?> ``` That folder might have zip or pdf files too that should not create a gallery

Original source