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,740 points
9,331 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,350 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,740 points
649 views
0 votes
1 answer

Python Script to pull data from Blockchain JSON

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

answered Sep 14, 2018 in Blockchain by digger
• 26,740 points
1,859 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
• 69,210 points
1,635 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 27, 2018 in Blockchain by Perry
• 17,100 points
3,727 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,740 points
43,813 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,350 points
5,927 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
673 views
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 30, 2018 in Blockchain by slayer
• 29,350 points
1,398 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP