How To Extract JSON NESTED Data In PHP

Dear Members I Have A Trouble And I Searched But Not Found Any Solution Can You Please Help Me

My JSON Data Is

{
  "response": {
    "status": "SUCCESS",
    "serialno": "2439418",
    "uniqueid": "BR044989"
    
  }
}

And I Want To Get uniqueid Can You Please Tell Me Ho To Get It Using PHP

You have to convert the json data to an associate array and find the ID in the array

$data  = '{
      "response": {
        "status": "SUCCESS",
        "serialno": "2439418",
        "uniqueid": "BR044989"
        
      }
    }';
    
    $expand = json_decode($data,true);
    
    if(isset($expand['response']['uniqueid'])){
    $uid = $expand['response']['uniqueid'];
    
    $uniqueid =   preg_replace("/[^0-9A-Za-z]/", "", $uid);
    echo $uniqueid;
}
else{
    echo "No Unique ID provided";
}
Sponsor our Newsletter | Privacy Policy | Terms of Service