Convert float to string in php?

前端 未结 6 1826
予麋鹿
予麋鹿 2021-02-18 13:01

Like:

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

Can it be done?

(it\'s for json_decode...)

6条回答
  •  逝去的感伤
    2021-02-18 13:34

    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.

提交回复
热议问题