user112707: 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?

user26873: 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


112707: <p>I am using the <code>easybitcoin.php</code> library and in my application. I use the <code>getreceivedbyaddress</code> method in php. It returns 0, but in my shell when I use bitcoin-cli it returns 0.000000000.</p>
<p>My question is, how can I return in php the same as the shell?</p>
<p>Tried this, <code>$ data2 = shell_exec ('bitcoin-cli getreceivedbyaddress address');</code> and it returns 0.00000000, but is there another way?</p>
 26873: <p>I think this is more of a PHP question versus bitcoin, but that's how PHP handles a zero float. <a href="https://www.php.net/manual/en/language.types.type-juggling.php" rel="nofollow noreferrer">https://www.php.net/manual/en/language.types.type-juggling.php</a></p>
<pre><code>$var = 0.00000000;
echo $var;
 
</code></pre>
<p>Returns:</p>
<pre><code>0
</code></pre>
<p>If you want to force a zero value to eight decimals you can use <code>number_format()</code> <a href="https://www.php.net/manual/en/function.number-format" rel="nofollow noreferrer">https://www.php.net/manual/en/function.number-format</a></p>
<pre><code>$var = 0.00000000;
$formatted = number_format($var, 8);
echo $formatted;
 
</code></pre>
<p>Returns:</p>
<pre><code>0.00000000
</code></pre>
