Read images from a directory using PHP

后端 未结 6 537
广开言路
广开言路 2020-12-19 16:35

I am wanting to find out if the following is possible with PHP inside WordPress.

Basically if I have a directory in my site called \"promos\" that consists of 1 to

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-19 17:07

    Go thou unto http://www.php.net/manual/en/ref.dir.php and look in particular at the scandir function. You can use something like:

    $images = array();
    foreach (scandir('somewhere') as $filename)
        if (is_an_image($filename)) $images[] = $filename;
    

    You get to write the is_an_image() function.

提交回复
热议问题