【发布时间】:2013-05-22 09:37:19
【问题描述】:
名为$chapter_theory_details的数组如下:
Array
(
[cs_class_id] => 2
[cs_subject_id] => 8
[chapter_id] => 103
[chapter_cs_map_id] => 81
[chapter_title] => Chemistry
[chapter_data] => Everything related to literature
)
我已使用以下说明将此数组分配给 smarty 模板:
$smarty->assign('chapter_theory_details', $chapter_theory_details);
现在我只想访问数组键值['chapter_data']。为此,我在 smarty 中编写了以下代码 sn-p,但无法获得所需的结果:
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center">
{if $chapter_theory_details}
Chapter's Theory
</td>
</tr>
<tr>
<td align="center" valign="top">
{foreach from=$chapter_theory_details item=chapter_theory}
<a href="#" onClick="get_chapter_theory_by_chapter({$chapter_theory.chapter_id}); return false;">{$chapter_theory.chapter_data}</a>
{/foreach}</a>
</td>
</tr>
{/if}
</table>
我得到的是输出2 8 1 8 C E,而不是获得所需的输出,即与文学相关的所有内容。任何人都可以帮助我获得所需的输出。提前致谢。
【问题讨论】: