3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set("precision", 20); // from 246 $from = "8.2" * "30"; // to 342 $to = "11.4" * "30"; printf("from %.20f to %.20f\n", $from, $to); $a = []; for ($i = $from; $i <= $to; $i++) { if (round($i) != floor($i)) { printf("index %.20f will be truncated to %d\n", $i, $i); } if ($i == 246) { echo "No output at all!"; } if ($i == 250) { echo "Still no output..."; } if ($i == 256) { echo "Still no output..."; } if ($i == 257) { echo "It works for {$i} and further numbers"; } $a[$i] = "test" . $i; } var_dump($a);
Output for 5.6.0 - 5.6.27, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.24, 7.4.0 - 7.4.13, 8.0.0
from 245.99999999999997157829 to 342.00000000000000000000 index 245.99999999999997157829 will be truncated to 245 index 246.99999999999997157829 will be truncated to 246 index 247.99999999999997157829 will be truncated to 247 index 248.99999999999997157829 will be truncated to 248 index 249.99999999999997157829 will be truncated to 249 index 250.99999999999997157829 will be truncated to 250 index 251.99999999999997157829 will be truncated to 251 index 252.99999999999997157829 will be truncated to 252 index 253.99999999999997157829 will be truncated to 253 index 254.99999999999997157829 will be truncated to 254 index 255.99999999999997157829 will be truncated to 255 It works for 257 and further numbersarray(97) { [245]=> string(25) "test245.99999999999997158" [246]=> string(25) "test246.99999999999997158" [247]=> string(25) "test247.99999999999997158" [248]=> string(25) "test248.99999999999997158" [249]=> string(25) "test249.99999999999997158" [250]=> string(25) "test250.99999999999997158" [251]=> string(25) "test251.99999999999997158" [252]=> string(25) "test252.99999999999997158" [253]=> string(25) "test253.99999999999997158" [254]=> string(25) "test254.99999999999997158" [255]=> string(25) "test255.99999999999997158" [257]=> string(7) "test257" [258]=> string(7) "test258" [259]=> string(7) "test259" [260]=> string(7) "test260" [261]=> string(7) "test261" [262]=> string(7) "test262" [263]=> string(7) "test263" [264]=> string(7) "test264" [265]=> string(7) "test265" [266]=> string(7) "test266" [267]=> string(7) "test267" [268]=> string(7) "test268" [269]=> string(7) "test269" [270]=> string(7) "test270" [271]=> string(7) "test271" [272]=> string(7) "test272" [273]=> string(7) "test273" [274]=> string(7) "test274" [275]=> string(7) "test275" [276]=> string(7) "test276" [277]=> string(7) "test277" [278]=> string(7) "test278" [279]=> string(7) "test279" [280]=> string(7) "test280" [281]=> string(7) "test281" [282]=> string(7) "test282" [283]=> string(7) "test283" [284]=> string(7) "test284" [285]=> string(7) "test285" [286]=> string(7) "test286" [287]=> string(7) "test287" [288]=> string(7) "test288" [289]=> string(7) "test289" [290]=> string(7) "test290" [291]=> string(7) "test291" [292]=> string(7) "test292" [293]=> string(7) "test293" [294]=> string(7) "test294" [295]=> string(7) "test295" [296]=> string(7) "test296" [297]=> string(7) "test297" [298]=> string(7) "test298" [299]=> string(7) "test299" [300]=> string(7) "test300" [301]=> string(7) "test301" [302]=> string(7) "test302" [303]=> string(7) "test303" [304]=> string(7) "test304" [305]=> string(7) "test305" [306]=> string(7) "test306" [307]=> string(7) "test307" [308]=> string(7) "test308" [309]=> string(7) "test309" [310]=> string(7) "test310" [311]=> string(7) "test311" [312]=> string(7) "test312" [313]=> string(7) "test313" [314]=> string(7) "test314" [315]=> string(7) "test315" [316]=> string(7) "test316" [317]=> string(7) "test317" [318]=> string(7) "test318" [319]=> string(7) "test319" [320]=> string(7) "test320" [321]=> string(7) "test321" [322]=> string(7) "test322" [323]=> string(7) "test323" [324]=> string(7) "test324" [325]=> string(7) "test325" [326]=> string(7) "test326" [327]=> string(7) "test327" [328]=> string(7) "test328" [329]=> string(7) "test329" [330]=> string(7) "test330" [331]=> string(7) "test331" [332]=> string(7) "test332" [333]=> string(7) "test333" [334]=> string(7) "test334" [335]=> string(7) "test335" [336]=> string(7) "test336" [337]=> string(7) "test337" [338]=> string(7) "test338" [339]=> string(7) "test339" [340]=> string(7) "test340" [341]=> string(7) "test341" [342]=> string(7) "test342" }