方法正确吗?
3种不同的数据类型:
$dir = "./content/media/artworks";
// ignore jpg-pictures if the name '_th' appears. And files with 'txt' extension.
$imgs = glob($dir.'/*{[!_th].jpg,*.[!txt]}', GLOB_BRACE);
// Just take jpg images with the name '_th'
$thumbs = glob($dir.'/*?_th.*');
// Just take files with 'txt' extensions
$txts = glob($dir.'/*?.txt');
第一个glob模式是错误的。这是这里* [!_th]。 Jpg并不意味着.jpg之前不是“ _th”。这意味着不允许在该点之前的最后一个字符'_',no't'和no'h'。
使用array_diff()获取所有不包含拇指的jpg文件。
$thumbs = glob($dir.'/*_th.jpg');
$jpgWithoutThumbs = array_diff(glob($dir.'/*.jpg'), $thumbs);