Bitcoin Forum
April 26, 2024, 06:18:42 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: SOLVED: PHP & API wallet balance help... need it to display properly ?  (Read 1664 times)
MoreBloodWine (OP)
Legendary
*
Offline Offline

Activity: 1050
Merit: 1001


View Profile
January 28, 2014, 12:20:42 AM
Last edit: January 28, 2014, 02:35:38 AM by MoreBloodWine
 #1

$blockchain_final_balance

Ok, so the above variable pulls my balance from the blockchain API ok but this is what it looks like.

6725

Which in reality it 0.00006725

If it had a 0 on the end it would be showing 67250, so what the API "blockchains fault" is doing is omitting the preceeding 0.0000

So... what bit of PHP do I need to wrap around $blockchain_final_balance to get it to display the current and all future values right.

By future values I mean if my balance was 101930240, I would expect it to show 1.01930240

Or if it was 023496380 I would expect it to display 0.23496380

Etc. Etc. Etc.

Basically what the blockchain API is doing is omitting all preceeding 0's, but there's always 8 digits ater the decimal. So I guess the code would have to count backwards, and aftr the 8th number add the decimal.

4829 becomes 0.00004829 etc.

0's at the end are never omitted, just the preceeding ones.

I just need it to always display the full, mind you correct, decimal value even if it includes an ass load of 0's in weird places.

ex: 000000500

To be decided...
Every time a block is mined, a certain amount of BTC (called the subsidy) is created out of thin air and given to the miner. The subsidy halves every four years and will reach 0 in about 130 years.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
MoreBloodWine (OP)
Legendary
*
Offline Offline

Activity: 1050
Merit: 1001


View Profile
January 28, 2014, 02:35:20 AM
 #2

Solved using: number_format( $blockchain_final_balance / 100000000, 8 );

To be decided...
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!