[{"Status":"FAILED","Message":"Trasaction Already Exist"}]
How to json_decode?
Currently using
$json=json_decode($response,true);
$status=$json["Status"];
$Message=$json["Message"];
but this is not working.
It is an array, you need to go to index 0
. Use print_r
or var_dump
in the future to see what you have.
$json = json_decode('[{"Status":"FAILED","Message":"Trasaction Already Exist"}]', TRUE);
$status=$json[0]["Status"];
$Message=$json[0]["Message"];
Example: https://3v4l.org/94BmB
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.