PHP Regex prefix with image file extension -
i want display files prefix: 7ws9xfd1rhvaupxh37nb_
must have file extension of .jpg, .png, .gif
these sample strings:
7ws9xfd1rhvaupxh37nb_magnifying_glass_icon.png 7ws9xfd1rhvaupxh37nb_url.gif 54a8sx555a4rrgsabwzq_korea.jpg 7ws9xfd1rhvaupxh37nb_6780969-cool-abstract-wallpaper.png 7ws9xfd1rhvaupxh37nb_wall_1409747331_multicolor-geometric-shapes.jpg
i've used regex no luck:
$key "7ws9xfd1rhvaupxh37nb"; $regex = '~^'.$key.'-.*\.((jpg)|(png)|(gif))$~'; $files = $files = preg_grep($regex, scandir("../temp/"));
there difference between - , _. check regex , modify slightly:
$regex = '~^'.$key.'_.*\.((jpg)|(png)|(gif))$~';
Comments
Post a Comment