0

my json response i am getting

$str = '{"Refund_Order_Result":{"reason":"","refund_status":0}} ';
$refoutput = json_decode($str,true);

print $refoutput->Refund_Order_Result->refund_status;

i want to get value of refund_status unable to do that . any way to get values

1
  • When you don't get the output you want, reduce it to something simple. In your case see what happens when you print $refoutput. Check if it is an object or an array and move forward from that. Commented Sep 2, 2016 at 9:29

3 Answers 3

3
echo "<pre>";print_r($refoutput);//see this is an array so use below code
echo $refoutput['Refund_Order_Result']['refund_status'];

or

$refoutput = json_decode($str);//remove true this wil return object
echo $refoutput->Refund_Order_Result->refund_status;

Note : When TRUE, returned objects will be converted into associative arrays.

You have used true so you are getting array not object

Sign up to request clarification or add additional context in comments.

Comments

2
$refoutput = json_decode($str,true);

the above variable will give an array, so u have to use code like given below...

$refoutput['Refund_Order_Result']['refund_status']

Comments

0
$refoutput['Refund_Order_Result']['refund_status'];

try this

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.