Like:
float(1.2345678901235E+19) => string(20) "12345678901234567890"
Can it be done?
(it's for json_decode...)
echo number_format($float,0,'.','');
note: this is for integers, increase 0 for extra fractional digits
echo number_format($float,10,'.',''); giving it a max of 10 decimal places. (Arbitrary, but I'm pretty sure it should be higher than 0).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.
I solved this issue by passing the argument JSON_BIGINT_AS_STRING for the options parameter.
json_decode($json, false, 512, JSON_BIGINT_AS_STRING)
See example #5 in the json_decode documentation
The only way to decode a float without losing precision is to go through the json and frame all the floats in quotation marks. By making strings of numbers.