Multiple gateways might have received the device’s transmission, so you’ll get an array in the JSON, each item being the details of one gateway. After parsing JSON into a PHP object, I assume you’ll also get an array. PHP is not my strong suit, but I’d assume something like:
// Not tested!
foreach($data->metadata->gateways as $gw) {
$rssi = $gw->rssi;
...
}
For a surprise, see also https://www.thethingsnetwork.org/forum/t/can-one-gateway-be-listed-twice-in-the-ttn-metadata-gateways-array/12364