I'm new to laravel and I'm trying to loop through this multidimensional array in the view of blade template but unable to get the elements. I tried using nested foreach but that doesn't work. I'm unsure what else to do. Please help
Array
(
[2] => Illuminate\Support\Collection Object
(
[items:protected] => Array
(
)
)
[3] => Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[ActivityID] => 1
[WaiverID] => 3
[ProgramID] => 1
[ActivityName] => Waiver3 Activity 1
[WaiverName] => Waiver 3
[ID] => 3
[WaiverDescription] =>
[ProgramID] => 1
)
[1] => stdClass Object
(
[ActivityID] => 2
[WaiverID] => 3
[ProgramID] => 1
[ActivityName] => Waiver3 Activity 2
[WaiverName] => Waiver 3
[ID] => 3
[WaiverDescription] =>
[ProgramID] => 1
)
[2] => stdClass Object
(
[ActivityID] => 3
[WaiverID] => 3
[ProgramID] => 1
[ActivityName] => Waiver3 Activity 3
[WaiverName] => Waiver 3
[ID] => 3
[WaiverDescription] =>
[ProgramID] => 1
)
)
)
)
When I do a foreach like this
@foreach ($waiverActivityforTable as$waiverActivityforTableValue)
@endforeach
I get:
[] [] [{"ActivityID":1,"WaiverID":3,"PHAProgramID":1,"ActivityName":"Waiver3
Activity 1","HCVWaiverName":"Waiver
3","ID":3,"HCVWaiverDescription":null,"phaProgramID":1},
{"ActivityID":2,"WaiverID":3,"PHAProgramID":1,"ActivityName":"Waiver3
Activity 2","HCVWaiverName":"Waiver
3","ID":3,"HCVWaiverDescription":null,"phaProgramID":1},
{"ActivityID":3,"WaiverID":3,"PHAProgramID":1,"ActivityName":"Waiver3
Activity 3","HCVWaiverName":"Waiver
3","ID":3,"HCVWaiverDescription":null,"phaProgramID":1}]
Tired nested foreach: I tried:
@foreach ($waiverActivityforTable as $waiverActivityforTableValue)
@foreach ($waiverActivityforTableValue as $test)
@endforeach
@endforeach
but I get an error: htmlspecialchars() expects parameter 1 to be string, object given
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire