3

I have the following already decoded json stored in $response = $result->response;:

 object(stdClass)#6 (5) {
  ["EmailAddress"]=> string(18) "email@gmail.com"
  ["Name"]=> string(0) ""
  ["Date"]=> string(19) "2011-10-09 19:32:00"
  ["State"]=> string(6) "Active"
  ["CustomFields"]=> array(1) {
    [0]=>object(stdClass)#7 (2) {
            ["Key"]=>string(2) "id"
            ["Value"]=>string(6) "Dl9lIz"
    }
  }

I can already access the main attributes (EmailAddress, Name, etc) with:

$email = $response->{'EmailAddress'};
print $email;

But I need to access the "Value" portion in the CustomFields object. I don't know how to dig that deep. I'm attempting to do this in PHP..

Any suggestions?

stewart715
  • 5,557
  • 11
  • 47
  • 80

1 Answers1

4

It is contained in the first element ([0]) of array CustomFields, so you can access it with an object operator (->) after the array index.

print $response->CustomFields[0]->Value;
Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390