SOLVEDI need help with some JSON Parsing using PHP...
I'll show you the code first then tell you where my problem lies.
<?php
$address = "1CaiKQcVSF2hY5sHgtirfK5ytLSZHXkxB2";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, "https://blockchain.info/address/$address?filter=1&format=json");
$output = curl_exec($ch);
curl_close($ch);
$a=json_decode($output,TRUE);
?>
<table class="table table-bordered">
<tr>
<th>
#
</th>
<th>
Date Sent
</th>
<th>
Address(es)
</th>
<th>
Amount Sent
</th>
</tr>
<?php $counter=1; ?>
<?php if (is_array($a["txs"])) { ?>
<?php foreach ($a["txs"] as $tx) { ?>
<tr>
<td>
<?php print_r($counter++); ?>
</td>
<td>
<?php print_r(date("Y-m-d",$tx["time"])); ?>
</td>
<td>
<?php print_r($tx["out"][0]["addr"]); ?>
</td>
<td>
<?php $inputs = $tx["inputs"][0]["prev_out"]; $value=0;
foreach($inputs as $num=>$inDetails){
if($inDetails["addr"]==$address){
$value=$inDetails["value"];
}
}
?>
<?php print_r(round($value/100000000, 4)); ?>BTC (<a href="https://blockchain.info/tx/<?php print_r($tx["hash"]); ?>">TX</a>)
</td>
</tr>
<?php } ?>
<?php } ?>
</table>
Right now, the Columns that work are all of them but the last one.
The last one is supposed to show the amount received in the transaction... but I had to code it so that it wouldn't just take the whole transaction value. I'm not quite sure where I messed up with that but it's somewhere...
If someone could help me with this, it'd be greatly appreciated... and I wouldn't mind emptying that wallet balance to you.