我用ThinkPHP写网站,部分代码如下:
$pic_all = $school_list['school_pic_allurl'];
$pic_list = array_filter(explode(",", $pic_all));
$pic_content = $school_list['school_pic_content'];
$pic_contents = array_filter(explode("|", $pic_content));
$pic_view['pic_url'] = array();
$pic_view['pic_text'] = array();
$pic_view['pic_url'] = $pic_list;
$pic_view['pic_text'] = $pic_contents;
$this->assign('pic_view',$pic_view);
$this->assign('pic_list',$pic_list);
$this->assign('pic_contents',$pic_contents);
其中 $school_list['school_pic_allurl']的值是诸如这样的
/data/uploads/pic/1.jpg,/data/uploads/pic/2.jpg,/data/uploads/pic/3.jpg
$school_list['school_pic_content']的值是诸如这样的
图片1说明|图片2说明|图片3说明
问题来了,在前端输出用这种写法是没问题的
{foreach $pic_list item="v" key="k"}
<div class="file-preview-fr
<img src="{$v|get_imgurl}" class="file-preview-image text-center" ti
</div>
{/foreach}
但一这样写就会出现未定义数组索引pic_url
{foreach name="pic_view" item="v" key="k"}
<div class="file-preview-fr
<img src="{$v.pic_url|get_imgurl}" class="file-preview-image text-center" ti
</div>
{/foreach}
我就是想把两个数组结合起来,再在前端循环输出
请问有办法解决吗?
最佳答案