I think im getting this simple thing confused. I just want to get the value of my key 'weeks' and 'days'. I have tried the following:
@foreach($years as $key3 => $year)
<h1>{{$key3}}</h1>
@foreach($year as $key2 => $months)
<p>{{$key2}}</p>
@foreach($months as $key1 => $days)
<p>{{$days['weeks']}}</p>
<p>{{$days->weeks}}</p> //try two//
@endforeach
@endforeach
@endforeach
which responds with this error:
Illegal string offset 'weeks'
this is an example of the array im trying to loop:
array:4 [▼
2016 => array:12 [▼
"01" => array:2 [▼
"weeks" => 5
"days" => "31"
]
can someone help me understand what I am doing wrong?
$keyas the key to your nestedforeachloops. You should rename them to different names so you don't mix them up. (Normally the inner$keywill overwrite the outer$key, but this is good practice)