鍍金池/ 問答/PHP  網(wǎng)絡安全/ php 顯示第二層 jsonObject 問題?

php 顯示第二層 jsonObject 問題?

我可以用 $data->{'msg'} 印第一層的值,例如 msg
但假設我要印第二層我要怎麼寫?比如說我要印 card_info 的 bin_code

{
    "status": 0,
    "msg": "Success",
    "amount": 100,
    "acquirer": "xxx",
    "currency": "xxx",
    "rec_trade_id": "xxx",
    "bank_transaction_id": "xxx",
    "order_number": "",
    "auth_code": "xxx",
    "card_info": {
        "issuer": "JxxA",
        "funding": 0,
        "type": 1,
        "level": "",
        "country": "xx x",
        "last_four": "x",
        "bin_code": "x",
        "country_code": "x"
    },
    "transaction_time_millis": 1531387581490,
    "bank_transaction_time": {
        "start_time_millis": "1531387581528",
        "end_time_millis": "1531387581528"
    },
    "bank_result_code": "0",
    "bank_result_msg": ""
}

他不是 array,所以我的方式完全不行==

回答
編輯回答
笑浮塵

你這個是json結構,解析成數(shù)組結構,再去獲取。

$array = json_decode($json, true);
$bin_code = $array['card_info']['bin_code'];
2017年4月29日 02:49