栏目图片回调求解,将栏目图片转换出来
"hits": "55",
"name": {
"id": "4",
"pid": "1",
"pids": "0,1",
"name": "女生头像",
"dirname": "nstx",
"pdirname": "touxiang/",
"child": 0,
"childids": 4,
"thumb": "2745",
"show": "1",
"setting": {
"linkurl": "",
"seo": {
"l
}, public function ppp_list_data($data) {
$rt = [];
// 这里根据项目的$data输出格式来定义PHP的数据写法,
// 每个接口的写法几乎不一样,下面是测试例子
if ($data['list']) {
foreach ($data['list'] as $t) {
$img = [];
foreach ($t['images'] as $i) {
$img[] = dr_get_file($i['file']);
}
$keywordsArr = [];
if($t['keywords']!='')
{
$keywordsArr = explode(',',rtrim($t['keywords'],','));
}
$rt[] = [
'title' => $t['title'],
'id' => $t['id'],
'keywords'=>$keywordsArr,
'comments'=>$t['comments'],
'author'=>$t['author'],
'avatar'=>dr_avatar($t['uid']),
'hits'=>$t['hits'],
'name' => dr_cat_value($t['catid']),
'uid'=>$t['uid'],
'catid'=>$t['catid'],
'comments'=>$t['comments'],
'favorites'=>$t['favorites'],
'support'=>$t['support'],
'thumb' => dr_thumb($t['thumb'], 200, 200),
'updatetime' => dr_fdate($t['_updatetime']),
'images' => $img,
];
}
}
return $rt;
}
public function ppp_list_data($data) { $rt = []; // 这里根据项目的$data输出格式来定义PHP的数据写法, // 每个接口的写法几乎不一样,下面是测试例子 if ($data['list']) { foreach ($data['list'] as $t) { $img = []; foreach ($t['images'] as $i) { $img[] = dr_get_file($i['file']); } $keywordsArr = []; if($t['keywords']!='') { $keywordsArr = explode(',',rtrim($t['keywords'],',')); } $rt[] = [ 'title' => $t['title'], 'id' => $t['id'], 'keywords'=>$keywordsArr, 'comments'=>$t['comments'], 'author'=>$t['author'], 'avatar'=>dr_avatar($t['uid']), 'hits'=>$t['hits'], 'name' => dr_cat_value($t['catid']), 'uid'=>$t['uid'], 'catid'=>$t['catid'], 'comments'=>$t['comments'], 'favorites'=>$t['favorites'], 'support'=>$t['support'], 'thumb' => dr_thumb($t['thumb'], 200, 200), 'updatetime' => dr_fdate($t['_updatetime']), 'images' => $img, ]; } } return $rt; }易学习public function ppp_list_data($data) { print_r($data); }这样写输出什么内容呢"data": [ { "title": "小葵好可爱哦!", "id": "604", "keywords": [ "可爱" ], "comments": "0", "author": "梦", "hits": "5", "name": { "id": "9", "pid": "2", "pids": "0,2", "name": "动漫壁纸", "dirname": "dongmanbizhi", "pdirname": "bizhi/", "child": 0, "childids": 9, "thumb": "2745", "show": "1", "setting": { "linkurl": "", "seo": { }, "template": { "pagesize": "10", "mpagesize": "10", "list": "list.html", "category": "category.html", "search": "search.html", "show": "show.html" }, "cat_field": null, "html": 0, "urlrule": 3 }, "displayorder": "0", "mid": "p", "topid": "2", "domain": "", "mobile_domain": "", "catids": [ "9" ], "tid": 1, "permission": [ ], "url": "/p/dongmanbizhi.html", "total": 73, "field": [ ] }, "uid": "1", "catid": "9", "favorites": "0", "support": "0", "thumb": "/static/assets/images/nopic.gif", "updatetime": "3天前", "images": [ ] },public function ppp_list_data($data) { $rt = []; // 这里根据项目的$data输出格式来定义PHP的数据写法, // 每个接口的写法几乎不一样,下面是测试例子 if ($data['list']) { foreach ($data['list'] as $t) { $img = []; foreach ($t['images'] as $i) { $img[] = dr_get_file($i['file']); } $keywordsArr = []; if($t['keywords']!='') { $keywordsArr = explode(',',rtrim($t['keywords'],',')); } $cat = dr_cat_value($t['catid']); $cat['thumb'] = dr_get_file($cat['thumb']); $rt[] = [ 'title' => $t['title'], 'id' => $t['id'], 'keywords'=>$keywordsArr, 'comments'=>$t['comments'], 'author'=>$t['author'], 'avatar'=>dr_avatar($t['uid']), 'hits'=>$t['hits'], 'name' => $cat, 'uid'=>$t['uid'], 'catid'=>$t['catid'], 'comments'=>$t['comments'], 'favorites'=>$t['favorites'], 'support'=>$t['support'], 'thumb' => dr_thumb($t['thumb'], 200, 200), 'updatetime' => dr_fdate($t['_updatetime']), 'images' => $img, ]; } } return $rt; }这是php基础语法了