I have the following JSON file that I need to extract a value and assign it to a PHP variable. The value I need is "icn".
{
"apiVersion": "1.0",
"data": {
"updated": 20160331141332,
"totalItems": 1,
"currentItemCount": 1,
"items": [
{
"birthDate": "20171101",
"fullName": "DOE,JOHN D",
"icn": "889081784V888383",
"pid": "55R1;60004"
}
]
}
}
I have tried the following but get no results.
$myjson = file_get_contents('http://testurl.org/info.json');
print_r(json_decode($myjson->data->items[0]->icn,true));
echo "<br>LAST-Error:"; echo json_last_error();
echo "<br>LAST-Error-Msg:"; echo json_last_error_msg();
Results are
LAST-Error:0
LAST-Error-Msg:No error