get all the images from a folder in php

前端 未结 9 2284
南方客
南方客 2020-12-04 14:37

I am using WordPress. I have an image folder like mytheme/images/myimages.

I want to retrieve all the images name from the folder myimages<

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 15:21

    when you want to get all image from folder then use glob() built in function which help to get all image . But when you get all then sometime need to check that all is valid so in this case this code help you. this code will also check that it is image

      $all_files = glob("mytheme/images/myimages/*.*");
      for ($i=0; $i'."

    "; } else { continue; } }

    for more information

    PHP Manual

提交回复
热议问题