php smarty 数组循环求助!!!
Array([0]=>Array([0]=><li><ahref="/yulu/1689.html"class="articleTitlefl"target="_blan...
Array
(
[0] => Array
(
[0] => <li> <a href="/yulu/1689.html" class="articleTitle fl" target="_blank">爱在滋生时,总有轻微的疼</a> <span class="gray9 fr">13-01-08</span> </li>
[1] => <li> <a href="/yulu/7955.html" class="articleTitle fl" target="_blank">影视剧中的经典浪漫台词</a> <span class="gray9 fr">13-12-13</span> </li>
[2] => <li> <a href="/yulu/7877.html" class="articleTitle fl" target="_blank">爱的四季</a> <span class="gray9 fr">13-12-12</span> </li>
)
[1] => Array
(
[0] => /yulu/1689.html
[1] => /yulu/7955.html
[2] => /yulu/7877.html
)
[2] => Array
(
[0] => 爱在滋生时,总有轻微的疼
[1] => 影视剧中的经典浪漫台词
[2] => 爱的四季
)
[3] => Array
(
[0] => 13-01-08
[1] => 13-12-13
[2] => 13-12-12
)
)
最后在模板文件里面怎么把他们写成这样的:
{<a href="地址">标题</a>日期:13-12-12<br>}(循环大括号内部的数据)
求大神帮忙用smarty 写出来可以吗?最好详细点小弟菜鸟啊!! 展开
(
[0] => Array
(
[0] => <li> <a href="/yulu/1689.html" class="articleTitle fl" target="_blank">爱在滋生时,总有轻微的疼</a> <span class="gray9 fr">13-01-08</span> </li>
[1] => <li> <a href="/yulu/7955.html" class="articleTitle fl" target="_blank">影视剧中的经典浪漫台词</a> <span class="gray9 fr">13-12-13</span> </li>
[2] => <li> <a href="/yulu/7877.html" class="articleTitle fl" target="_blank">爱的四季</a> <span class="gray9 fr">13-12-12</span> </li>
)
[1] => Array
(
[0] => /yulu/1689.html
[1] => /yulu/7955.html
[2] => /yulu/7877.html
)
[2] => Array
(
[0] => 爱在滋生时,总有轻微的疼
[1] => 影视剧中的经典浪漫台词
[2] => 爱的四季
)
[3] => Array
(
[0] => 13-01-08
[1] => 13-12-13
[2] => 13-12-12
)
)
最后在模板文件里面怎么把他们写成这样的:
{<a href="地址">标题</a>日期:13-12-12<br>}(循环大括号内部的数据)
求大神帮忙用smarty 写出来可以吗?最好详细点小弟菜鸟啊!! 展开
2个回答
展开全部
你的数组格式是错误的,需要修改,例如去掉数组后面3个元素变为一位数组: $arr=Array ( [0] => <li> <a href="/yulu/1689.html" class="articleTitle fl" target="_blank">爱在滋生时,总有轻微的疼</a> <span class="gray9 fr">日期:13-01-08</span> </li> [1] => <li> <a href="/yulu/7955.html" class="articleTitle fl" target="_blank">影视剧中的经典浪漫台词</a> <span class="gray9 fr">日期:13-12-13</span> </li> [2] => <li> <a href="/yulu/7877.html" class="articleTitle fl" target="_blank">爱的四季</a> <span class="gray9 fr">日期:13-12-12</span> </li> )
然后在html文件写上:
<?php foreach($arr as $val){ echo $val;}?>
用smarty语法替换上述语句就行了
然后在html文件写上:
<?php foreach($arr as $val){ echo $val;}?>
用smarty语法替换上述语句就行了
追问
不是这样的 ,数组是我匹配出来得到的,改起来很不方便,还有我是想在smarty模板里面循环,希望能得到你的最新答案!!万分感谢!!
追答
好吧,将你的数组改为这种形式$arr=array(array('href','标题','日期'),array(‘href2’,'标题2','日期2'),array('href3','标题3','日期3'))
然后在html文件写上
{$val[1]}日期:{$val[2]}";
}?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询