how loop through a JSON Array of bitcoin transaction data

0 votes

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>';
}
Sep 21, 2018 in Blockchain by digger
• 26,550 points
46 views

1 answer to this question.

0 votes
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

answered Sep 21, 2018 by slayer
• 29,170 points

Related Questions In Blockchain

0 votes
1 answer

In hyperledger, how many number of ordering node can take up a transaction?

There are two types to implement ordering: 1. ...READ MORE

answered Jun 25, 2018 in Blockchain by Omkar
• 67,660 points

edited Jun 28, 2018 by Omkar 270 views
0 votes
1 answer

How to set the hex-encoded data field in a Web3j Ethereum transaction?

You can use the "data" field of ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,660 points
196 views
+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,080 points
87 views
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
92 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
172 views
0 votes
1 answer
0 votes
1 answer

How to write a program to get details of ERC tokens?

You can use Javascript with the Metamask ...READ MORE

answered Jul 13, 2018 in Blockchain by slayer
• 29,170 points
53 views
0 votes
2 answers