switch ($flags) { case 128: // GLOB_BRACE preg_match( '%(.+)\{(?:(.+))+\}%', $pattern, $matches ); $path= $matches[1]; $mimes= explode(',',$matches[2]); $res= array(); foreach ($mimes as $mime) { $res= array_merge( $res, glob( $path . '*' . $mime ) ); } break; default: $res= glob( $pattern, $flags ); if ( $res === false ) { $res= array(); } }