0

如何解释这个 JSON 解码数组?它似乎比我习惯处理的更复杂的数组,因此将不胜感激。

谢谢。

array(1){
    [0]=> object(stdClass)#1 (11){
        ["id"]=> string(5) "72324"
        ["txid"]=> string(64) "**bitcoin_tx_id**"
        ["from"]=> string(34) "**bitcoin_address**"
        ["to"]=> string(20) "email@somewhere.com"
        ["amount"]=> int(10000000)
        ["amount_sent"]=> int(0)
        ["note"]=> string(0) ""
        ["time"]=> float(1379742767000)
        ["to_addr"]=> string(34) "**bitcoin_address**"
        ["read"]=> string(1) "1"
        ["balance"]=> string(10) "0.10000000"
    }
}
4

1 回答 1

2

它返回一个对象数组,看起来你只是将它转储到标准输出。从变量内部折腾输出json_decode(),您可以像这样访问它:

$decoded = json_decode($data);

foreach($decoded as $obj) {
   echo "ID: " . $obj->id . ', ';
   echo "TXID: " . $obj->txid . ', ';
   echo "From: " . $obj->from . ', ';
   echo "To: " . $obj->to. ', ';
   // ...

   echo "<br>";
}

如果你想json_decode()返回一个关联数组(大多数人都习惯了),只需将第二个参数设置为true.

于 2013-09-23T18:45:28.300 回答