Author

Topic: SOLVED: PHP & API wallet balance help... need it to display properly ? (Read 1689 times)

legendary
Activity: 1064
Merit: 1001
Solved using: number_format( $blockchain_final_balance / 100000000, 8 );
legendary
Activity: 1064
Merit: 1001
$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
Jump to: