我想知道是否有任何方法可以簡化這一點。它基本上將 JSON API 解碼為數組,然后將每個value對象從對象添加到$utxos數組。如果可能,這就是我實際擁有并希望簡化的內容:$utxos = array();$unspent = json_decode(file_get_contents("https://blockchain.info/unspent?active=1LaiteuxHEH4GsMC9aVmnwgUEZyrG6BiTH"), true)["unspent_outputs"];foreach ($unspent as $utxo) array_push($utxos, $utxo["value"]);
1 回答

心有法竹
TA貢獻1866條經驗 獲得超5個贊
這就是我想出的:
$unspent = json_decode(file_get_contents("https://blockchain.info/unspent?active=1LaiteuxHEH4GsMC9aVmnwgUEZyrG6BiTH"), true)["unspent_outputs"]; $utxos = array_column($unspent, "value")
- 1 回答
- 0 關注
- 164 瀏覽
添加回答
舉報
0/150
提交
取消