选择名称包含字符php的文件

时间:2015-12-02 10:47:47

标签: php regex

所以我想选择名称中包含 -bpfull 的图片,例如 5ac46ae912feaaf004b2fdb88f1c8a1a-bpfull.png

我有很多图像,我想要一个正则表达式,这是我从文件夹中选择图像的小代码:

$dir = $upload_dir['basedir'].'/avatars/2/';

如果有人有任何想法我会非常感激。

1 个答案:

答案 0 :(得分:3)

你可以使用phps glob()函数

foreach (glob($dir . "*-bpfull.*") as $filename) {
    echo "$filename . "\n";
}