douqiju2520 2019-01-06 15:54
浏览 80
已采纳

php json_encode显示数字不正确的数组[重复]

This question already has an answer here:

This is my array

$data['myarray'] = ["1" => 1.2, "10" => 0.911, "50" => 0.811, "100" => 0.37];

if using json_encode it will display like json_encode($data['myarray']

{"1":{"1":1.2,"10":0.91100000000000003,"50":0.81100000000000005,"100":0.37}}

I don't understand why my var has change to other number

</div>
  • 写回答

1条回答 默认 最新

  • dpbf62565 2019-01-06 18:10
    关注

    add this config

    ini_set('serialize_precision', 14); ini_set('precision', 14); This is issue from php 7.1

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?