我是Mustache的新手,请耐心等待我:)
我有这样的数组:
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"
)
)
)
)
)
我如何用小胡子迭代这个。
我想在学校上课。
提前致谢。
我的模板是:
{{#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}}
在这一刻,我可以向所有学校展示,但首先要附上课程。 提前谢谢。
答案 0 :(得分:0)
foreach ($myArray[0]['school'] as $item){
if($item['school_name'] == "Biology"){ //Biology for example
// some code
}