【发布时间】:2014-01-13 17:31:33
【问题描述】:
我基于 PHP 中的一些操作创建了以下数组结构。
array
(
[7] => array(
[id] => 7
[page] => dashboard
[text] => Text 3
)
[1] => array(
[id] => 1
[page] => index
[text] => Text 2
)
[3] => array(
[id] => 3
[page] => index
[text] => Text 3
)
}
我正在使用下面的 Smarty 模板来创建基于这个数组结构的表,它工作正常。
<table>
<tr>
<th>{text key='sitetour+page'}</th>
<th>{text key='sitetour+text'}</th>
</tr>
{foreach from=$allSteps key='id' item='step'}
<tr>
<td>{$step.page}</td>
<td>{$step.text}</td>
</tr>
{/foreach}
</table>
我正在寻找的是,基于“page”的值,我需要为“page”的每个唯一值创建表,而不是为所有值的单个表。
示例如下。
当前输出:(单表不考虑页值)
page | text
---------------------
dashboard | text 3
index | text 2
index | text 3
预期输出:(根据页面值损坏的 2 个表)
dashboard
---------------------
text 3
index
---------------------
text 2
text 3
我在这里搜索时找不到任何样本。提前致谢。
【问题讨论】: