Link to home
Start Free TrialLog in
Avatar of BR
BRFlag for Türkiye

asked on

PHP json object

Dear Experts,
I use PHP,
I need to get a result inside an object which is inside Json.
I get the parrent result like below.

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec($ch);

var_dump ( $obj = json_decode($server_output));

echo $yeniobj= ($obj->result);

//Result is 
object(stdClass)#1 (10) { ["result"]=> string(90) "{"ReturnCode":0,"ReturnData":null,"Confirm":null,"TimeStamp":"04.11.2019 10:43:34"}" ["id"]=> int(135) ["exception"]=> NULL ["status"]=> int(5) ["isCanceled"]=> bool(false) ["isCompleted"]=> bool(true) ["isCompletedSuccessfully"]=> bool(true) ["creationOptions"]=> int(0) ["asyncState"]=> NULL ["isFaulted"]=> bool(false) }

echo $yeniobj= ($obj->result);

//Result is

{"ReturnCode":0,"ReturnData":null,"PaymentConfirm":null,"TimeStamp":"04.11.2019 10:43:34"}

Open in new window


But I need to result of the ReturnCode information.
How can I get that? thank you
Avatar of leakim971
leakim971
Flag of Guadeloupe image

$ReturnCode = $yeniobj["ReturnCode"];

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Brian Tao
Brian Tao
Flag of Taiwan, Province of China image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BR

ASKER

Dear Experts,
when I do this, the result is below...

echo $yeniobj= ($obj->result);
echo $ReturnCode = $yeniobj["ReturnCode"];
var_dump ($ReturnCode);

When I do that, the result is :

{string(1) "{"
You're using leakim971's code. It does not work!
Avatar of BR

ASKER

Thank you so much Brian Tao