I'm trying to get images in a directory (with extensions jpg, jpeg, png, gif) using glob(). Here's my code:
$images = glob("uploads/*.{jpg,jpeg,png,gif}", GLOB_BRACE);
Because glob()
is case sensitive, it's unable to find files with upper case and mixed case extensions. I want to find files with UPPERCASE (JPG, JPEG, PNG, GIF) and mixed case (JpG, jPeG, PNg, gIF) extensions.
I managed it to work using sql_regcase() on one extension, but it is now deprecated anyway.
$pattern = sql_regcase("jpg");
$images = glob("uploads/*.$pattern", GLOB_BRACE);
Is there any flexible solution for this problem?