Переход по вложенным уровням в JSON
подскажите как перейти на разные уровни вложенности в JSON. Имеется следующая структура JSON:
{
"head": [
"Код",
и т.д
],
"years": [
{
"year": 2015,
"rows": [
[
Получение и декодирование происходит с помощью функции:
public static function getPlans()
{
return \Cache::remember('plan_list', 60, function() {
$header = [];
$ydata = [];
try {
$json = file_get_contents("http://umu.vspu.ac.ru/plany/get-list-next");
$ydata = json_decode($json, true);
$rowIndex = 0;
foreach ($ydata as $year => $data) {
if ($rowIndex == 0) {
$header = $data;
$rowIndex++;
continue;
}
foreach ($data as $i => $row) {
foreach ($row as $j => $col) {
if (is_array($col)) {
$d = '';
foreach ($col as $link) {
$d .= '<a itemprop="' . self::mapEduPropByIndex2($j) . '" target="_blank" href="' . $link . '">Скачать</a><br>';
}
$ydata[$year][$i][$j] = $d;
} else {
if (strpos($col, 'http') === 0) {
$ydata[$year][$i][$j] = '<a itemprop="' . self::mapEduPropByIndex2($j) . '" target="_blank" href="' . $col . '">Скачать</a>';
}
}
}
}
}
} catch (\Exception $e) {
}
return ['header' => $header, 'data' => $ydata];
});
}
Вывод происходит следующим способом:
<div itemscope itemtype="http://obrnadzor.gov.ru/microformats/Edu">
<ul class="nav nav-tabs" role="tablist" style="margin: 0">
{% for year, plans in plans_data.data %} {% if not loop.first %}
<li style="margin: 0; list-style: none;" {% if year=='2020' %}class="active" {% endif %}><a href="#plans_{{ year }}" role="tab" data-toggle="tab">{{ year }}</a></li>
{% endif %} {% endfor %}
</ul>
<div class="tab-content">
{% for year, plans in plans_data.data %} {% if not loop.first %}
<div role="tabpanel" class="tab-pane {% if year=='2020' %}active{% endif %}" id="plans_{{ year }}">
<table class="table table-striped table-responsive small" itemprop="eduOp">
<tr>
{% for h in plans_data.header %}
<th>{{ h }}</th>
{% endfor %}
</tr>
{% for row in plans %}
<tr itemprop="eduOp">
{% for key,col in row %}
<td {{ docsObj.mapEduPropByIndex(key) |raw }}>{{ col |raw}}</td>
{% endfor %}
<td class="robobob" itemprop="eduPr"><a href="#">Информация о практиках представлена в таблице</a></td>
</tr>
{% endfor %}
</table>
</div>
{% endif %} {% endfor %}
</div>
</div>
По итогу должен получиться следующий результат:

А получается что вместо Года просто выводится years