I am using the getResponse api to get subscriber updates. This is what prints aftervar_dump($result);
var_dump($result);
object(stdClass)#2 (1) { ["updated"]=> int(1) }
How to extract / decode / encode the result to request a key: "update" and get its value: 1?
thank
// json object. $ contents = '{"firstName": "John", "lastName": "Doe"}'; // Option 1: through the use of an array. $ jsonArray = json_decode ($ contents, true); $ key = "firstName"; $ firstName = $ jsonArray [$ key]; // Option 2: through the use of an object. $ jsonObj = json_decode ($ contents); $firstName = $jsonObj->$key;
, , json_decode - JSON stdClass, -, :
json_decode
stdClass
$string = '{"updated":1}'; $array = json_decode($string, true); echo $array['updated'];
updated , :
updated
$obj = json_decode($string); echo $obj->updated;