Listing all images in a directory using PHP

前端 未结 8 770
悲&欢浪女
悲&欢浪女 2021-01-04 08:39

I have the code below that lists all the images in a folder, the problem is that it finds some files ( a . and a ..) that I am not sure what they are so I a

8条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 08:53

    Using balphp's scan_dir function: https://github.com/balupton/balphp/blob/765ee3cfc4814ab05bf3b5512b62b8b984fe0369/lib/core/functions/_scan_dir.funcs.php

    scan_dir($dirPath, array('pattern'=>'image'));

    Will return an array of all files that are images in that path and all subdirectories, using a $path => $filename structure. To turn off scanning subdirectories, set the recurse option to false

提交回复
热议问题