列出JSON目录中的所有图像 [英] list all images in directory in JSON

查看:99
本文介绍了列出JSON目录中的所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以CLEAN json格式列出目录中的所有图像.我需要它看起来像这样:

I need away to list all images in a directory in a CLEAN json format. I need it to look like this:

URLLINK:"image of where the image is"

这就是我所需要的.

推荐答案

$files = array();

$dir = opendir('/tmp');
while ($file = readdir($dir)) {
    if ($file == '.' || $file == '..') {
        continue;
    }

    $files[] = $file;
}

header('Content-type: application/json');
echo json_encode($files);

类似这样的事情. 您可以将其转换为所需的任何结构

Something like this. You can convert it in any structure you want

这篇关于列出JSON目录中的所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆