mysql - Convert string with array of json (PHP) -
i stored array of json in mysql string
[{"id": 1, "mark": 5}, {"id": 2, "mark": 3}, {"id": 3, "mark": 2}]
when try use
@foreach ($places $place) @foreach ($place->rates $rate) {{var_dump($rate->marks)}} @endforeach @endforeach
there problem. $rate->marks string. how shoul decode array?
upd
of course tried use json_decode, returns error
htmlentities() expects parameter 1 string, array given
solved
i', stupid. problem not in json_decode. tried print result {{ }} needs string argument.
there no rate
in json, , no marks
.
$json = '[{"id": 1, "mark": 5}, {"id": 2, "mark": 3}, {"id": 3, "mark": 2}]'; $places = json_decode ($json); foreach ($places $place) var_dump($place->mark);
design code laravel, online debug does't have feature.
let me know.
Comments
Post a Comment