3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "Numeric strings will be converted into an integer:\n"; var_dump(array( -1 => -1, 1 => 1, '1' => '1', '-1' => '-1', '1.1' => '1.1', 's1' => 's1', )); echo "Floating point numbers will be converted into an integer:\n"; var_dump(array( -1 => -1, 0 => 0, 1 => 1, -1.9 => -1.9, 0.9 => 0.9, 1.9 => 1.9 )); echo "Booleans will be converted into an integer:\n"; var_dump(array( 0 => 0, 1 => 1, true => true, false => false, )); echo "NULL will be converted into an empty string:\n"; var_dump(array( '' => '', null => null, ));
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Numeric strings will be converted into an integer: array(4) { [-1]=> string(2) "-1" [1]=> string(1) "1" ["1.1"]=> string(3) "1.1" ["s1"]=> string(2) "s1" } Floating point numbers will be converted into an integer: Deprecated: Implicit conversion from float -1.9 to int loses precision in /in/m3SGv on line 16 Deprecated: Implicit conversion from float 0.9 to int loses precision in /in/m3SGv on line 21 Deprecated: Implicit conversion from float 1.9 to int loses precision in /in/m3SGv on line 22 array(3) { [-1]=> float(-1.9) [0]=> float(0.9) [1]=> float(1.9) } Booleans will be converted into an integer: array(2) { [0]=> bool(false) [1]=> bool(true) } NULL will be converted into an empty string: array(1) { [""]=> NULL }
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Numeric strings will be converted into an integer: array(4) { [-1]=> string(2) "-1" [1]=> string(1) "1" ["1.1"]=> string(3) "1.1" ["s1"]=> string(2) "s1" } Floating point numbers will be converted into an integer: array(3) { [-1]=> float(-1.9) [0]=> float(0.9) [1]=> float(1.9) } Booleans will be converted into an integer: array(2) { [0]=> bool(false) [1]=> bool(true) } NULL will be converted into an empty string: array(1) { [""]=> NULL }

preferences:
249.45 ms | 404 KiB | 400 Q