How get value from JSON array in PHP

Viewed 13

My JSON response received from an API call like below -

object(stdClass)#7 (2) {
  ["result"]=>
  object(stdClass)#6 (1) {
    ["faces"]=>
    array(1) {
      [0]=>
      object(stdClass)#4 (5) {
        ["attributes"]=>
        array(0) {
        }
        ["confidence"]=>
        int(100)
        ["coordinates"]=>
        object(stdClass)#5 (6) {
          ["height"]=>
          int(546)
          ["width"]=>
          int(546)
          ["xmax"]=>
          int(844)
          ["xmin"]=>
          int(298)
          ["ymax"]=>
          int(770)
          ["ymin"]=>
          int(224)
        }
        ["face_id"]=>
        string(64) "5805a70f97911f49cdd9e143cd40fc95023bceb6b989f794823d4525b46bc153"
        ["landmarks"]=>
        array(0) {
        }
      }
    }
  }
  ["status"]=>
  object(stdClass)#8 (2) {
    ["text"]=>
    string(0) ""
    ["type"]=>
    string(7) "success"
  }
}

I am trying to get the value of 'face_id' from JSON response using below but not working properly.

$jsonData = json_decode($response[0]['result'], true);
$faceid = $jsonData['faces']['face_id'];

I am new in JSON array operation. What will be the correct syntax to get value of 'face_id' from JSON response mentioned above.

0 Answers
Related