get all the images from a folder in php

前端 未结 9 2277
南方客
南方客 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:04

    //path to the directory to search/scan
            $directory = "";
             //echo "$directory"
            //get all files in a directory. If any specific extension needed just have to put the .extension
            //$local = glob($directory . "*"); 
            $local = glob("" . $directory . "{*.jpg,*.gif,*.png}", GLOB_BRACE);
            //print each file name
            echo "
      "; foreach($local as $item) { echo '
    • '.$item.'
    • '; } echo "
    ";

提交回复
热议问题