简体   繁体   中英

how loop through a JSON Array of bitcoin transaction data

My code is:

$requesturl='https://blockchain.info/tx-index/1fda663d2584425f192eae045d3809950883ebe50f2222f98ef7d31f414f3f96?format=json';
$ch=curl_init($requesturl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$cexecute=curl_exec($ch);
curl_close($ch);
$result = json_decode($cexecute,true);
// to get the first i use 
echo $result['out'][0]['addr'];
to get the second I use
echo $result['out'][0]['addr']; 

Now my requirement is to look through the array using for each but its throwing error:

foreach ($result['out'] as $adressee) {
   echo $adressee.'<br>';
}
 for($i=0; $i<count($result['out']); $i++) {

   echo $result['out'][$i]["addr"].'<br>';
  }

Some Sample codes in PHP manual helped me come up with this solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM