Home > Net >  PHP glob select multiple folders
PHP glob select multiple folders

Time:01-26

How can I get a listing of all images having specific extension from multiple folders using the PHP glob() function?

$images = glob("data/{'./assets/img/post/birthday-wishes/*.png','./assets/img/post/birthday-quotes/*.png'}/*", GLOB_BRACE);
echo $images;

CodePudding user response:

Try this code if helpful

$images = glob("data/{assets/img/post/birthday-wishes/*.png,assets/img/post/birthday-quotes/*.png}", GLOB_BRACE);
echo $images;

CodePudding user response:

Use multiple asterisks with the glob() function

$images = glob('./assets/img/post/*/*.png');
print_r($images);
  •  Tags:  
  • Related