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
• 27,620 points
66 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Try this code, it worked for me:

$balance = $json["balance"];
echo $balance;
answered Sep 3, 2018 by slayer
• 29,040 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
• 27,620 points
20 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
• 27,620 points
149 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
• 65,850 points
33 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
• 16,450 points
38 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
• 27,620 points
1,558 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,040 points
754 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,040 points
34 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.