4
好的,我有一個看起來像一個數組。symfony2和樹枝上的子陣列
[0] => Array (
first_name => j,
last_name => b,
times => Array(
[0] => Array(
[in1] => a date here
[out1] => a date here
[in2] => a date here
[out2] => a date here
)
[1] => Array(
[in1] => another date here
[out1] => another date here
[in2] => another date here
[out2] => another date here
)))
我已經簡化了陣列的SO佈局着想的樣子......
這份名單將時常有開始陣列中的超過100個不同的人,將所有需輸出到瀏覽器......這很好,我可以做..
{% for entity in entity %}
<h3>{{ entity.first_name }} {{ entity.last_name }} ({{ start|date("m/d/Y") }} - {{ end|date("m/d/Y")}})</h3>
<table = border="1" cellpadding="5" cellspacing="0">
<thead>
<tr>
<th>Date</th>
<th>In</th>
<th>Lunch Out</th>
<th>Lunch In</th>
<th>Out</th>
<th>Extra In</th>
<th>Extra Out</th>
<th>Total Time</th>
</tr>
</thead>
<tbody>
{% for times in entity.times %}
<tr>
<td>{{ entity.times.daydate|date("M jS Y") }} </td>
<td>{{ entity.times.in1 is empty ? "" : entity.times.in1|date("h:i A") }}</td>
<td>{{ entity.times.out1 is empty ? "" : entity.times.out1|date("h:i A") }}</td>
<td>{{ entity.times.in2 is empty ? "" : entity.times.in2|date("h:i A") }}</td>
<td>{{ entity.times.out2 is empty ? "" : entity.times.out2|date("h:i A") }}</td>
<td>{{ entity.times.in3 is empty ? "" : entity.times.in3|date("h:i A") }}</td>
<td>{{ entity.times.out3 is empty ? "" : entity.times.out3|date("h:i A") }}</td>
<td>{{ entity.times.totaltime }} Hours</td>
</tr>
{% endfor%}
</tbody>
</table>
{% endfor %}
這就是我目前的枝杈代碼...什麼我需要幫助,是因爲每一個「實體」擁有.times子數組,也需要循環..什麼是正確的方法來做到這一點?
不工作...的'
{{time.bar}}
'心不是渲染..即使有一個新的緩存... – Justin 2012-04-28 20:20:23它實際上是我的查詢這是給我的麻煩不小樹枝。 ..但這正是如何去做的,所以我們會選擇答案供將來參考其他人。 – Justin 2012-05-18 18:04:35