Checking for file-extensions in PHP with Regular expressions

前端 未结 7 2069
伪装坚强ぢ
伪装坚强ぢ 2020-12-28 17:30

I\'m reading all the files in a single directory and I want to filter on JPG,JPEG,GIF and PNG.

Both capital and small letters. Those are the only files to be accepte

相关标签:
7条回答
  • 2020-12-28 18:08

    This works out for me

    $string = "your-file-name.jpg";
    preg_match("/\b(\.jpg|\.JPG|\.png|\.PNG|\.gif|\.GIF)\b/", $string, $output_array);
    

    Best.

    0 讨论(0)
提交回复
热议问题