PHP parsing metadata level

Hi - Can someone tell me what is the correct syntax to parse the metadata level of the json data to get say RRSI? I can get the app_id, dev_id and the payload with:

    $json_data = json_decode($line,true);
    $app_id = $json_data['app_id'];
    $dev_id = $json_data['dev_id'];	
    $time = $json_data['metadata']['time'];
    $rssi = $json_data['metadata']['gateways']['rssi']; // gives error				
    $state = $json_data['payload_fields']['ValveState'];

regards
Russel
solved : - I needed $rssi = $json_data[‘metadata’][‘gateways’][0][‘rssi’];l

Be carefull with [‘gateways’][0], because if a node is “listened” by many gateways it’l be a number of array positions [‘gateways’][0], [‘gateways’][1]. [‘gateways’][2] equivalent to the gateways listening, and all of them will show differente RSSI

Thanks for that - what is the correct (or safer option?)

Loop through the gateway array - you end up with a mix of gateway data that doesn’t change often - like it’s location - and data specific to that particular uplink - like timestamp, channel etc.

$gateways = $json['metadata']['gateways'];

foreach($gateways as $gateway) {

	$gtw_id = $gateway['gtw_id'];
	
	$gtw_altitude	= $gateway['altitude'];
	$gtw_trusted	= $gateway['gtw_trusted'];
	$gtw_latitude	= $gateway['latitude'];
	$gtw_longitude	= $gateway['longitude'];
	
	$gtw_timestamp	= $gateway['timestamp']; 
	$gtw_channel	= $gateway['channel']; 
	$gtw_rssi		= $gateway['rssi'];
	$gtw_snr		= $gateway['snr'];

}

ok, thank you for the reply