3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function test($input) { $foo = range ('A', 'D'); var_dump($foo[(0.999 - $input)*10]); } test(0.7); test(1); test(0.6); test(0.5); test(2);
based on 2Kg1u
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
string(1) "C" string(1) "A" string(1) "D" Notice: Undefined offset: 4 in /in/fFgUW on line 5 NULL Notice: Undefined offset: -10 in /in/fFgUW on line 5 NULL
Output for hhvm-3.12.0
string(1) "C" string(1) "A" string(1) "D" Notice: Undefined index: 4.99 in /in/fFgUW on line -1 NULL Notice: Undefined index: -10.01 in /in/fFgUW on line -1 NULL
Output for hhvm-3.10.0
string(1) "C" string(1) "A" string(1) "D" Notice: Undefined index: 4.99 in /in/fFgUW on line 5 NULL Notice: Undefined index: -10.01 in /in/fFgUW on line 5 NULL
Output for 4.3.0 - 5.2.17
string(1) "C" string(1) "A" string(1) "D" Notice: Undefined offset: 4 in /in/fFgUW on line 5 NULL Notice: Undefined offset: -10 in /in/fFgUW on line 5 NULL