scandir to only show folders, not files

后端 未结 4 2031
一整个雨季
一整个雨季 2021-01-01 22:49

I have a bit of PHP used to pulled a list of files from my image directory - it\'s used in a form to select where an uploaded image will be saved. Below is the code:

4条回答
  •  臣服心动
    2021-01-01 23:29

    The easiest and quickest will be glob with GLOB_ONLYDIR flag:

    foreach(glob('../images/*', GLOB_ONLYDIR) as $dir) {
        $dirname = basename($dir);
    }
    

提交回复
热议问题