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.

check online

$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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -