2

I want to show amount of bitcoins up to 8 decimal points. I have stored the value in Satoshi but when I try to convert the satoshi to BTC by dividing the satoshi value with 100000000 I am getting invalid result. here is my code.

            $res = 3535/100000000;
            echo $res;

the output of the above code is 3.535E-5 isntead 0.00003535. please tell me the proper solution.

Zahid Iqbal
  • 112
  • 7
  • 2
    `number_format` is probably what your are searching for – empiric Sep 10 '19 at 13:55
  • 1
    No its not duplicate question. Problem to show a number up to 8 places. code is working up to 7 places when I try to increase one more decimal place it gives wrong output. – Zahid Iqbal Sep 10 '19 at 13:55

1 Answers1

3
echo number_format(3535/100000000, 8);

Where 8 is the count of 0's. For example for 3535/1000000000 you need to write

echo number_format(3535.0/1000000000, 9);
Rob Mkrtchyan
  • 220
  • 1
  • 7