Hello to all. There is an array obtained from json by json_decode

stdClass Object ( [center_lat] => 51.785635290118 [center_lng] => 55.1109775 [zoom] => 16 [type] => map [marks] => Array ( [0] => stdClass Object ( [id] => 1 [content] => [type] => Point [coords] => Array ( [0] => 51.785721792459 [1] => 55.111133068123 ) [circle_size] => 0 ) ) ) 

I need to pull the coordinates and assign variables to them. Alas, in all examples there is only a reference to the value via $data->name . This will work for center_lat , center_lng , zoom , type . But I do not know how to get the coordinates coordinates.

Tell me who knows, and then the nesting of the array from me shook my whole soul?

    1 answer 1

    For example, so

     $std = new stdclass(); $coord = new stdclass(); $coord->coords = [2, 5]; $std->marks = [ $coord ]; var_dump($std->marks[0]->coords[0]); 

    But in your case, sort of

     $object->marks[0]->coords[0];