PHP + JSON Webservice - Reading array

0

I would like to interpret a JSON with PHP , where:

{"data":
  {
    "nome1":João,
    "status":["Ativo"]
  }
}

$retorno = json_decode($jsonRet);

$nome1 = $retorno->data->nome1;
$status = $retorno->data->status;

echo "nome1: ".$nome1." / ".$status;die;

The nome1 , I can read this normally, but the status that is enclosed in brackets does not work, returns with nothing ...

How would it be to read correctly?

    
asked by anonymous 04.12.2017 / 19:06

1 answer

2

The key status is array , to access it you must enter the index you want to get. In your case, as there is only one index, it is accessible by:

$status = $retorno->data->status[0];
    
04.12.2017 / 19:13