3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array('foo' => 3.0, 'bar' => 3.1); echo json_encode($data, JSON_PRESERVE_ZERO_FRACTION);
Output for 5.6.6 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.5 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
{"foo":3.0,"bar":3.1}
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.5
Notice: Use of undefined constant JSON_PRESERVE_ZERO_FRACTION - assumed 'JSON_PRESERVE_ZERO_FRACTION' in /in/srIhv on line 3 Warning: json_encode() expects parameter 2 to be long, string given in /in/srIhv on line 3

preferences:
176.83 ms | 402 KiB | 224 Q