3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (substr(PHP_VERSION, 0, 5) !== '7.1.6') die('Meh'); function test($label = '') { global $t; $t2 = microtime(1); if ($label) echo str_pad($label . ': ', 32, '.', STR_PAD_RIGHT) . ' ' . 1000 * ($t2 - $t) . 'ms' . "\n"; $t = $t2; } $c = 30; $c2 = 3000; test(); for ($i = $c; $i--;) { for ($j = $c2; $j--;) { $a = [0, 1, 2, 3, 4]; unset($a[0]); } } test('unset list => map'); for ($i = $c; $i--;) { for ($j = $c2; $j--;) { $a = ['c' => 0, 1, 2, 3, 4]; unset($a['c']); } } test('unset map => list'); for ($i = $c; $i--;) { for ($j = $c2; $j--;) { $a = ['c' => 0, 'd' => 1, 2, 3, 4]; unset($a['c']); } } test('unset map => map');
Output for 7.1.6
unset list => map: ............. 6.8089962005615ms unset map => list: ............. 10.053873062134ms unset map => map: .............. 9.3669891357422ms

preferences:
47.14 ms | 401 KiB | 6 Q