View Single Post
  #4   IP: 153.99.39.110
Old 2016-08-16, 12:49 AM
Katelyn Katelyn is offline
初级会员
 
Join Date: 2008-02-04
Posts: 2
Katelyn 现在声名狼藉
Default

8
down vote
If you want more than one extension searched, then preg_grep() is an alternative for filtering:
Code:
$files = preg_grep('~\.(jpeg|jpg|png)$~', scandir($dir_f));
Though glob has a similar extra syntax. This mostly makes sense if you have further conditions, add the ~i flag for case-insensitive, or can filter combined lists.
or

glob("{$dir}*.{jpg,*​jpeg,gif,ico,png}", GLOB_BRACE). This would work as well for multiple extensions.
Reply With Quote