Json解码不工作//不打印[关闭]

I want to json decode and print the row confirmations.

My code:

  $urls = file_get_contents("https://chain.so/api/v2/address/LTC/3NwuCjaN3cnvq8F1jhD13ikBoVMMYPmh3h");
  $array = json_decode($urls,TRUE);
  // print_r($array,TRUE);
  $confirmation = $array[0]['confirmations'];

Question: Why doesn't my code work?

This is the json you are getting from the URL :

{ 
"status" : "success",
"data" : {
"network" : "LTC",
"address" : "3NwuCjaN3cnvq8F1jhD13ikBoVMMYPmh3h",
"balance" : "0.05581900",
"received_value" : "0.05581900",
"pending_value" : "0.00000000",
"total_txs" : 1,
"txs" : [
  {
    "txid" : "94883d8d67f10dcf34b20bf2af5867a9f9dc195f2b6c8d789315fd8b764274a6",
    "block_no" : 1344095,
    "confirmations" : 76,
    "time" : 1515011556,
    "incoming" : {
      "output_no" : 0,
      "value" : "0.05581900",
      "spent" : null,
      "inputs" : [
        {
          "input_no" : 0,
          "address" : "3EguWJJBMpKKyWFq1qgU4SL82uHvdb1HPq",
          "received_from" : {
            "txid" : "08643a119af3312921dbab5eeea8d526f4c6d29dd95cd7a45fb51ea838b87e53",
            "output_no" : 1
          }
        }
      ],
      "req_sigs" : 1,
      "script_asm" : "OP_HASH160 e92b4546a40a63ebdd262596192269c1798d70dc OP_EQUAL",
      "script_hex" : "a914e92b4546a40a63ebdd262596192269c1798d70dc87"
    }
  }
]
},
"code" : 200,
"message" : ""
 }

As you can see for the structure, and decoding to an associative array as you are doing, you would need to change your code to the following , in order to access the confirmations property:

$confirmation = $array['data']['txs'][0]['confirmations'];