i have key and value datas. key is an array. i want to foreach this key data. I use laravel 5. my json_decoded array like :
Collection {#1288 ▼
#items: array:4 [
"{"id":1,"title":"abc","path":"abc-path"}" => 19
]
}
But i can not fetch key data like i wanted my code :
@foreach($trendings as $key => $value)
{{ $key->id }}
@endforeach
it gives ' Trying to get property of non-object ' error. but if write code like :
@foreach($trendings as $key => $value)
{{ $key }}
@endforeach
it gives me
{"id":1,"title":"abc","path":"abc-path"}
but i want them use in my html. how can i fetch them ?
In my opinion, view should not execute a json_decode. I expect view to get already decoded variables, i think that if your data is not completly decoded something is missing before the view.
Of course i would rather work on fixing what's wrong before than patching your view.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.