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,所以我的方式完全不行==

ibeautiful
浏览 337回答 1
1回答

慕村225694

你这个是json结构,解析成数组结构,再去获取。 $array = json_decode($json, true); $bin_code = $array['card_info']['bin_code'];
打开App,查看更多内容
随时随地看视频慕课网APP