關於smarty二維數組循環顯示,如何寫section語句。

關於smarty二維數組循環顯示,如何寫section語句。附上二維數組。

 

[code language=php]$obj=array(array('cheng','male','wuhan'),
                 array('zhao','male','nanchang'),
                 array('li','male','wuhan'));[/code]
我想要的效果是用表格把結果列出來。每行各是一維數組,單元格是一維裏的元素。。
我想了一個上午弄不出頭緒。。smarty手冊上沒給出數組的例子,只寫告終果。
哪位大牛幫我解決下問題

最佳答案

{section name=sec loop=$obj} {section name=subsec loop=$obj[sec]} {$obj[sec][subsec]} {/section} {/section}

 

 

 

--------------------------------------------————————————————————php

 

 

 

<table>html

{section name=sec loop=$obj} <tr>     {section name=subsec loop=$obj[sec]}         <td>{$obj[sec][subsec]}</td>     {/section} </tr> {/section} </table>
相關文章
相關標籤/搜索