Thursday, 6 April 2017

how to get json data string in php

http://stackoverflow.com/questions/26825235/how-to-get-json-data-with-php

7down voteaccepted
Assuming $data contains what was returned from the server, you do:
$object = json_decode($data);
$last = $object->last;
or:
$array = json_decode($data, true);
$last = $array['last'];
When you leave out the second argument to json_decode, it returns an object, and you access the part you want as an object property. If you give the second argument true, it returns an associative array, and you access the element using array notation.

No comments:

Post a Comment