[英]iterate array of arrays in mustache
I am new to Mustache, please bear with me :) 我是小胡子的新手,请多多包涵:)
I have array like this: 我有这样的数组:
array(1) (
"school" => array(2) (
0 => array(12) (
"school_code" => string(4) "Organics"
"school_name" => string(27) "Biology"
"school_city" => string(4) "Bremmen"
"classes" => array(1) (
0 => array(14) (
"location" => string(4) "south1"
"startdate" => string(10) "2013-11-11"
"enddate" => string(10) "2013-12-05"
)
)
)
1 => array(12) (
"school_code" => string(4) "Anorganics"
"school_name" => string(27) "Biology"
"school_city" => string(4) "Augsburg"
"classes" => array(3) (
1 => array(14) (
"location" => string(4) "south2"
"startdate" => string(10) "2013-11-11"
"enddate" => string(10) "2013-12-05"
)
2 => array(14) (
"location" => string(4) "south3"
"startdate" => string(10) "2013-08-22"
"enddate" => string(10) "2014-01-05"
)
3 => array(14) (
"location" => string(4) "south4"
"startdate" => string(10) "2013-11-11"
"enddate" => string(10) "2013-12-05"
)
)
)
)
)
How i can iterate this in mustache. 我怎么能在胡子上迭代这个。
i wanna show classes by school. 我想按学校上课。
Thanks in advance. 提前致谢。
My template is: 我的模板是:
{{#school}}
{{#has_missing_classes}}
<tr>
<td class="location faded">Unavailable</td>
<td class="address">Unavailable</td>
<td class="address">Unavailable</td>
<td class="actions">
<a></a>
</td>
</tr>
<tr class="separator">
<td colspan="4"></td>
</tr>
{{/has_missing_classes}}
{{#classes}}
<tr>
<td class="Location"><a href="{{dashboard_uri}}/classes/edit/{{Location}}">{{Location}}</a></td>
<td {{^StartDate}}class="faded"{{/StartDate}}>
{{StartDate}}
{{^StartDate}}Unavailable{{/StartDate}}
</td>
<td class="actions">
<a href="{{dashboard_uri}}/classes/edit/{{Id}}" class="edit" data-tooltip>Update Information</a>
</td>
</tr>
{{/classes}}
{{^classes}}
<tr>
<td colspan="5" class="empty">
<p>
No records found.<br />
</p>
</td>
</tr>
{{/classes}}
{{/school}}
In this moment i can show all schools, but just first have classes attached. 在这一刻,我可以显示所有学校,但首先要附加课程。 Thanks in advance.
提前致谢。
foreach ($myArray[0]['school'] as $item){
if($item['school_name'] == "Biology"){ //Biology for example
// some code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.