PHP+JSON Webservice - Reading array

Asked

Viewed 76 times

0

I’d like to play 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 that way normally, but status that is between brackets does not work, returns with nothing...

How would it be to read correctly?

1 answer

2


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

$status = $retorno->data->status[0];
  • Solved, Thank you!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.