Php 如何循环通过比特币交易数据的JSON数组
我的代码是:Php 如何循环通过比特币交易数据的JSON数组,php,json,foreach,blockchain,Php,Json,Foreach,Blockchain,我的代码是: $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);
$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'];
现在,我的要求是查看使用for each但其抛出错误的数组:
foreach ($result['out'] as $adressee) {
echo $adressee.'<br>';
}
foreach($result['out']作为$adressee){
echo$adressee.“
”;
}
for($i=0;$i)这个问题的标题到底是什么意思?@Daskwuff这个问题只是用户想要循环一个json响应。这个json数据是否是比特币交易信息无关紧要。
for($i=0; $i<count($result['out']); $i++) {
echo $result['out'][$i]["addr"].'<br>';
}