0

I am using the easybitcoin.php library and in my application. I use the getreceivedbyaddress method in php. It returns 0, but in my shell when I use bitcoin-cli it returns 0.000000000.

My question is, how can I return in php the same as the shell?

Tried this, $ data2 = shell_exec ('bitcoin-cli getreceivedbyaddress address'); and it returns 0.00000000, but is there another way?

1 Answer 1

1

I think this is more of a PHP question versus bitcoin, but that's how PHP handles a zero float. https://www.php.net/manual/en/language.types.type-juggling.php

$var = 0.00000000;
echo $var;
 

Returns:

0

If you want to force a zero value to eight decimals you can use number_format() https://www.php.net/manual/en/function.number-format

$var = 0.00000000;
$formatted = number_format($var, 8);
echo $formatted;
 

Returns:

0.00000000
2
  • thnx @m1xolyd1an, a question, my application need connect with the api blockchain.com or can i only work bitcoin core?
    – Aisakk
    Jan 22, 2021 at 16:28
  • Yes you can build an application with just bitcoin-core.
    – m1xolyd1an
    Jan 23, 2021 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.