Can PHP's glob() be made to find files in a case insensitive manner?

前端 未结 10 1910
遥遥无期
遥遥无期 2020-11-29 08:15

I want all CSV files in a directory, so I use

glob(\'my/dir/*.CSV\')

This however doesn\'t find files with a lowercase CSV extension.

10条回答
  •  無奈伤痛
    2020-11-29 08:34

    To make it work with all extensions use:

    $extension = 'some_extension';
    glob('my/dir/*.preg_replace('/(\w)/e', "'['.strtoupper($1).strtolower($1).']'", $extension));
    

提交回复
热议问题