我想打印以下以$all_class_subjects
smarty 模板命名的数组:
Array
(
[4] => Array
(
[class_id] => 5
[class_name] => V
[class_order] => 0
[class_subject_assign] => 0
[class_added_date] => 1365837028
[class_updated_date] => 1365837028
[class_added_staff_id] => ff8d4a5ea6bf11dce105aa2fa7b959b8
[class_updated_staff_id] => ff8d4a5ea6bf11dce105aa2fa7b959b8
[sub_data] => Array
(
[0] => Chemistry
[1] => Mathematics
)
)
)
以及我试图打印数组的代码(并非所有元素都只有class_name,并且sub_data
数组中存在主题名称):
{if $all_class_subjects}
{foreach from=$all_class_subjects item=class_subject_data}
<tr>
<td width="20%">{$class_subject_data.class_name|capitalize}</td>
<td width="40%">
{foreach from=class_subject_data.sub_data item=subject key=subject_name}
<b>{$subject.subject_name}</b>
<br />
{/foreach}
{/foreach} h
</td>
</tr>
但我无法打印 sub_data 数组的主题名称。因此,请告诉我们如何打印这些主题名称来帮助我们。请帮我只打印那些主题名称,其他事情我会自己处理。提前致谢。