3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arraydata = array('foo' => 3.0, 'bar' => 3.1); $jsondata = json_encode($arraydata); var_dump($arraydata); echo json_encode($arraydata, JSON_PRESERVE_ZERO_FRACTION); echo json_decode($jsondata);
based on srIhv
Output for 7.1.0 - 7.2.0
array(2) { ["foo"]=> float(3) ["bar"]=> float(3.1) } {"foo":3.0,"bar":3.1} Recoverable fatal error: Object of class stdClass could not be converted to string in /in/rNUMJ on line 7
Process exited with code 255.
Output for 5.6.6 - 7.0.20
array(2) { ["foo"]=> float(3) ["bar"]=> float(3.1) } {"foo":3.0,"bar":3.1} Catchable fatal error: Object of class stdClass could not be converted to string in /in/rNUMJ on line 7
Process exited with code 255.
Output for 5.5.0 - 5.6.5
array(2) { ["foo"]=> float(3) ["bar"]=> float(3.1) } Notice: Use of undefined constant JSON_PRESERVE_ZERO_FRACTION - assumed 'JSON_PRESERVE_ZERO_FRACTION' in /in/rNUMJ on line 6 Warning: json_encode() expects parameter 2 to be long, string given in /in/rNUMJ on line 6 Catchable fatal error: Object of class stdClass could not be converted to string in /in/rNUMJ on line 7
Process exited with code 255.