Extract data from Json url result php

0 votes

I am trying to run a url for getting balance of a address.

URL: https://dogechain.info/api/v1/address/balance/DMr3fEiVrPWFpoCWS958zNtqgnFb7QWn9D

Which gives the JSON:

{
    "balance": "1682049.83191666",
    "success": 1
}

I am trying to extract the "balance" with the code:-

<?php
    $url = "https://dogechain.info/api/v1/address/balance/DMr3fEiVrPWFpoCWS958zNtqgnFb7QWn9D";
    $json = json_decode(file_get_contents($url), true);
    $balance = json("balance")

    echo $balance
?>  

But it returns nothing. What am I doing wrong?

Sep 3, 2018 in Blockchain by digger
• 26,550 points
123 views

1 answer to this question.

0 votes

Try this code, it worked for me:

$balance = $json["balance"];
echo $balance;
answered Sep 3, 2018 by slayer
• 29,050 points

Related Questions In Blockchain

0 votes
1 answer

How to parse Json data from remote server?

Yes, you can do it use the ...READ MORE

answered Aug 17, 2018 in Blockchain by digger
• 26,550 points
35 views
0 votes
1 answer

Python Script to pull data from Blockchain JSON

Try this: print r.json()['address'],' has ', r.json()['n_tx'], 'tra ...READ MORE

answered Sep 14, 2018 in Blockchain by digger
• 26,550 points
242 views
0 votes
1 answer

Get specific JSON data value using array from Coin Market Cap API

use inArray function. example: $.getJSON("//api.coinmarketcap.com/v1/ticker/?limit=0", function(data) { ...READ MORE

answered Oct 8, 2018 in Blockchain by Omkar
• 67,480 points
65 views
0 votes
1 answer

How to retrieve data from a block to a blockchain?

web3.eth.getTransaction(txHash) will returns transaction details like blockHash, transactionIndex, ...READ MORE

answered Jun 26, 2018 in Blockchain by Perry
• 17,020 points
106 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,550 points
3,056 views
+2 votes
5 answers

How do I parse this JSON array in PHP?

/** * Firstly collect the ...READ MORE

answered Sep 3, 2018 in Blockchain by slayer
• 29,050 points
906 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to extract Ethereum Blockchain data?

You are using web3.eth.getTransaction(txHash) web3.eth.getTransaction(txHash) will only return info ...READ MORE

answered Jul 29, 2018 in Blockchain by slayer
• 29,050 points
57 views