3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
24.22 ms | 404 KiB | 5 Q