3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [round(-0.1), round(0.1)]; // [-0,0] var_dump($array); // Array ( [0] => -0 [1] => 0 ) $json = json_encode($array, JSON_PRESERVE_ZERO_FRACTION); // "[-0,0]" $array = json_decode($json); // [0,0] var_dump($array); // Array ( [0] => 0 [1] => 0 )
based on fQK6s
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.23, 7.4.0 - 7.4.11, 8.0.0alpha1 - rc2
array(2) { [0]=> float(-0) [1]=> float(0) } array(2) { [0]=> float(-0) [1]=> float(0) }