I'm currently working on a website project on Symfony 2.8. But I have a problem : I want to display information from a JSON object. However, I need to do three nested for-loops in order to do what I want.
So here's my code chunks :
The array I want to browse :
element stdClass Object =>
(
[partschemes] => Array
(
[0] => ( [id] => 1 )
)
[decodedPartitions] => Array
(
[0] => stdClass Object
(
[partitions] => Array
(
[0] => stdClass Object
(
[name] => WINDOWS
[type] => primary
[size] => -
[filesystem] => fat32
)
[1] => stdClass Object
(
[name] => DATA*
[type] => primary
[size] => 256 Mo
[filesystem] => fat32
)
)
)
)
)
My twig template :
{% for i, disk in element.decodedPartitions %}
<tr>
<th class="text-center" rowspan="3" width="10%">
<a href="{{ app.request.baseUrl }}/partscheme/details/{{ element.partschemes[i].id }}" class="btn btn-info" title="{{ 'button.details' | trans }}">Disk {{ i }}</a>
</th>
</tr>
{% for j, part in disk.partitions %}
<tr>
<th class="text-center" width="10%">Partition {{ j }}</th>
<td>
{% for k, partInfo in part %}
{{ k }}: {{ partInfo }}<br>
{% endfor %}
</td>
</tr>
{% endfor %}
{% endfor %}
And as a result, the generated page shows me that, without information of different partitions:
---------------------------------
| Partition 0 | |
Disk 1 |-------------|----------|
| Partition 1 | |
---------------------------------