Warm tip: This article is reproduced from serverfault.com, please click

Convert float to string in php?

发布于 2011-07-29 17:16:48

Like:

float(1.2345678901235E+19) => string(20) "12345678901234567890"

Can it be done?

(it's for json_decode...)

Questioner
tweety
Viewed
0
Karoly Horvath 2011-07-30 01:21:40
echo number_format($float,0,'.','');

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