Glob is not working when directory name with special characters like square brackets “[ ]”

前端 未结 4 1386
长发绾君心
长发绾君心 2021-01-13 01:47

I have issue while using glob function when path directory with square brackets.

// Example 1 - working
$path = \'temp\'. DIRECTORY_SEPARATOR .\'dir - name\'         


        
4条回答
  •  梦毁少年i
    2021-01-13 02:23

    This is what I use:
    $path = str_replace(['[',']',"\f[","\f]"], ["\f[","\f]",'[[]','[]]'], $path);

    All in one line.

提交回复
热议问题