In my code I want to print a specific value i.e. ticket
from JSON data but when I do it I got Notice: Trying to get property of non-object
error every time I don't know what I am doing wrong in it
Here is my JSON array dump
array(3) {
["status"]=>
int(200)
["msg"]=>
string(2) "OK"
["result"]=>
array(6) {
["ticket"]=>
string(79) "w-_xdRcVDJQ~55de39b726745a28~1505246565~def~FzuGpPpNoQEus6lK~1~Dhyp8PJM83-pMwAe"
["captcha_url"]=>
string(50) "https://myurl.com/images/FzuGpPpNoQEus6lK.png"
["captcha_w"]=>
int(160)
["captcha_h"]=>
int(70)
["wait_time"]=>
int(0)
["valid_until"]=>
string(19) "2017-09-12 20:17:46"
}
}
Here is my PHP Code
$response = file_get_contents($url);
$obj = json_decode($response, TRUE);
$printjson = $obj->result->ticket;
echo $printjson;