BCLtd BCLtd - 6 months ago 48
JSON Question

JSON - PHP - Reading Key

I have the following code below, which I am trying to run to save the key in the json to a PHP varible. However, for some reason it's just not doing anything - although it seems my code is right, any ideas where I am going wrong?

$json = file_get_contents('url');
$data = json_decode($json,true);

$id = $data['s_id'];



and the json from the external URL looks like this



You have an array wrapping the object

$id = $data[0]['s_id'];