'thumb' => dr_thumb($t['thumb'], 600, 200),
'zhanshitu'=> dr_string2array($t['zhanshitu']),
如上,一個(gè)是單圖字段,一個(gè)是多圖字段,多圖返回的是一個(gè)數(shù)組,可以怎樣自定義函數(shù)將這個(gè)數(shù)組輸出的不是 圖片的數(shù)字,而是具體的圖片路徑了?
['image1路徑','image1路徑','image1路徑'],用于json返回一個(gè)路徑的數(shù)組
$mb = [];
$test = dr_string2array($t['zhanshitu']);
foreach($test as $tt) {
$mb[] = dr_get_file($tt);
}
然后再
public function ztxm_list_data($data) {
$rt = [];
if ($data) {
foreach ($data as $t) {
$rt[] = [
'id' => $t['id'],
'title' => $t['title'],
'thumb' => dr_thumb($t['thumb'], 600, 200),
//多圖數(shù)組
'zhanshitu'=> dr_string2array($t['zhanshitu']),
];
}
}
return $rt;
}
我是這樣寫的,這個(gè)多圖字段該如何循環(huán)?
public function ztxm_list_data($data) { $rt = []; if ($data) { foreach ($data as $t) { $mb = []; $test = dr_string2array($t['zhanshitu']); foreach($test as $tt) { $mb[] = dr_get_file($tt); } $rt[] = [ 'id' => $t['id'], 'title' => $t['title'], 'thumb' => dr_thumb($t['thumb'], 600, 200), 'zhanshitu'=> $mb, ]; } } return $rt; }