dimanche 29 avril 2018

Cannot get data from json_encoded array

i have key and value datas. key is an array. i want to foreach this key data. I use laravel 5. my json_encoded 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)

 

@endforeach

it gives ' Trying to get property of non-object ' error. but if write code like :

 @foreach($trendings as $key => $value)

     

   @endforeach

it gives me

{"id":1,"title":"abc","path":"abc-path"}

but i want them use in my html. how can i fetch them ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire