Convert Float To String In Php?


Answer :

echo number_format($float,0,'.','');


note: this is for integers, increase 0 for extra fractional digits



$float = 0.123;
$string = sprintf("%.3f", $float); // $string = "0.123";


It turns out json_decode by default casts large integers as floats. This option can be overwritten in the function call:



$json_array = json_decode($json_string, , , 1);


I'm basing this only on the main documentation, so please test and let me know if it works.



Comments

Popular posts from this blog

530 Valid Hostname Is Expected When Setting Up IIS 10 For Multiple Sites

C Perror Example

Converting A String To Int In Groovy