从URL-php中搜索JSON对象


Search JSON objects from URL -php

我有一个返回的url:

[{"account":"123","address":"abc","category":"receive","amount":12,"confirmations":10,"tx":"6f8fa99a88c266ce403e0108f926adc02288f89be30adc298485961ac332a314"},
{"account":"123","address":"def","category":"send","amount":-5,"fee":-0.01,"confirmations":8,"tx":"6f8fa99a88c266ce403e0108f926adc02288f89be30adc298485961ac332a314"},
{"account":"123","address":"ghi","category":"receive","amount":23.59,"confirmations":5,"tx":"8b20ed5bf4a4d299bad42fd49b8aabf6456366b235288f34f79d9f2321cd11c9"}]

我尝试了SO的各种选项,但只能显示所有对象/值,或者使用下面的代码显示值。但无法搜索所有对象,只能从一个特定对象中检索数据

$string = file_get_contents('http://...');
$json_a=json_decode($string,true);
echo $json_a[0][txid];

所有对象都有一些完全相同的值。我想循环浏览特定"地址"的所有对象,然后如果找到,显示"金额、确认、tx"值。

如何在php中检索和使用?

$array = json_decode($string, true);
foreach ( $array as $k=>$item ) {
    if ( $item['address']=='def' ) {
        /* Display other values for this record */
        echo 'Amount: ' . $item['amount'];
        /* etc. */
    };
};