I have the below JSON data
in server. How I can extract only "SUCCESS
" as output in PHP
, where SUCCESS
is result of Status
which is inside object
of data
. i.e "status":"SUCCESS",
{
"response":{
"status":true,
"statusCode":"0",
"statusDescription":"Amount Debited",
"data":{
"balanceamount":"528",
"status":"SUCCESS",
"statuscode":"0",
"statusdescription":"Amount Debited",
"debitedamount":"2",
"orderid":"hj",
"refId":"4450"
}
},
"checksum":"23e97234820f5987189245e4216e89425472c2fe2c957749743b21d828efae67"
}
UPDATE
$ch = curl_init(); // initiate curl
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1); // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); // define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$output = curl_exec ($ch); // execute
//echo "Request_Json= ".$data_string;
//echo "Response_Json=".$output;
echo $output;
This $output
gives me the above JSON.
But when I use your answer I get output empty. Anything I'm doing wrong ?