3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $keys = ['1', '6', 4, '8', 'f', 200, '-1']; $one = []; foreach ($keys as $k) { $one[$k] = 'set'; } $two = []; foreach ($keys as $k) { $two[(int)$k] = 'set'; } var_dump($one, $two);
based on tjgB6
Output for 5.6.0 - 7.2.0
array(7) { [1]=> string(3) "set" [6]=> string(3) "set" [4]=> string(3) "set" [8]=> string(3) "set" ["f"]=> string(3) "set" [200]=> string(3) "set" [-1]=> string(3) "set" } array(7) { [1]=> string(3) "set" [6]=> string(3) "set" [4]=> string(3) "set" [8]=> string(3) "set" [0]=> string(3) "set" [200]=> string(3) "set" [-1]=> string(3) "set" }