thinkphp5 如何将带分隔符的字符串转换成索引数组,并且遍历到前台

转自https://blog.csdn.net/qq_40270754/article/details/87988423

感谢作者的无私分享!

控制器

//转为字符串
$label_array = implode(",", $change_one);


//将字符串转为索引数组
$arr = explode ( ',', $label_array );
$this->assign(array(
'arr' => $arr,
));
 

模板中

<ul>
{volist name="arr" id="vo"}
<a href="/">{$vo}</a>
{/volist}
</ul>
 

前台效果



原文地址:https://www.cnblogs.com/huhewei/p/12066480.html