3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rand = []; $max = 10000; for ($i = 0; $i < $max; $i++) { $rand[bin2hex(random_bytes(10))] = $i; } $max = 1000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $keys = []; $arr2 = []; foreach ($rand as $k => $v) { $arr2[$k] = $v; $keys[] = $k; } } printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max); $max = 1000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $arr2 = []; foreach ($rand as $k => $v) { $arr2[$k] = $v; } $keys = array_keys($rand); } printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max);
Output for 8.1.1
Took 0.0008735 seconds per execution Took 0.0007100 seconds per execution
Output for 8.1.0
Took 0.0008108 seconds per execution Took 0.0007170 seconds per execution
Output for 8.0.14
Took 0.0009084 seconds per execution Took 0.0007512 seconds per execution
Output for 8.0.13
Took 0.0009007 seconds per execution Took 0.0007421 seconds per execution
Output for 8.0.12
Took 0.0008894 seconds per execution Took 0.0007394 seconds per execution
Output for 8.0.11
Took 0.0008117 seconds per execution Took 0.0007928 seconds per execution
Output for 8.0.10
Took 0.0009539 seconds per execution Took 0.0007113 seconds per execution
Output for 8.0.9
Took 0.0008597 seconds per execution Took 0.0007767 seconds per execution
Output for 8.0.8
Took 0.0007559 seconds per execution Took 0.0006814 seconds per execution
Output for 8.0.7
Took 0.0009371 seconds per execution Took 0.0007814 seconds per execution
Output for 8.0.6
Took 0.0007536 seconds per execution Took 0.0007541 seconds per execution
Output for 8.0.5
Took 0.0008960 seconds per execution Took 0.0007693 seconds per execution
Output for 8.0.3
Took 0.0008726 seconds per execution Took 0.0007389 seconds per execution
Output for 8.0.2
Took 0.0009264 seconds per execution Took 0.0006703 seconds per execution
Output for 8.0.1
Took 0.0008807 seconds per execution Took 0.0006217 seconds per execution
Output for 8.0.0
Took 0.0007444 seconds per execution Took 0.0006213 seconds per execution
Output for 7.4.27
Took 0.0007391 seconds per execution Took 0.0006167 seconds per execution
Output for 7.4.26
Took 0.0007280 seconds per execution Took 0.0006176 seconds per execution
Output for 7.4.25
Took 0.0007374 seconds per execution Took 0.0006174 seconds per execution
Output for 7.4.24
Took 0.0007286 seconds per execution Took 0.0006145 seconds per execution
Output for 7.4.23
Took 0.0007310 seconds per execution Took 0.0006174 seconds per execution
Output for 7.4.22
Took 0.0007342 seconds per execution Took 0.0006201 seconds per execution
Output for 7.4.21
Took 0.0007325 seconds per execution Took 0.0006170 seconds per execution
Output for 7.4.20
Took 0.0007313 seconds per execution Took 0.0006157 seconds per execution
Output for 7.4.19
Took 0.0007364 seconds per execution Took 0.0006209 seconds per execution
Output for 7.4.18
Took 0.0007363 seconds per execution Took 0.0006186 seconds per execution
Output for 7.4.16
Took 0.0007325 seconds per execution Took 0.0006179 seconds per execution
Output for 7.4.15
Took 0.0007308 seconds per execution Took 0.0006163 seconds per execution
Output for 7.4.14
Took 0.0007358 seconds per execution Took 0.0006195 seconds per execution
Output for 7.4.13
Took 0.0007320 seconds per execution Took 0.0006130 seconds per execution
Output for 7.4.12
Took 0.0007250 seconds per execution Took 0.0006132 seconds per execution
Output for 7.4.11
Took 0.0007242 seconds per execution Took 0.0006212 seconds per execution
Output for 7.4.10
Took 0.0007492 seconds per execution Took 0.0006134 seconds per execution
Output for 7.4.9
Took 0.0007225 seconds per execution Took 0.0006088 seconds per execution
Output for 7.4.8
Took 0.0007340 seconds per execution Took 0.0006197 seconds per execution
Output for 7.4.7
Took 0.0007337 seconds per execution Took 0.0006414 seconds per execution
Output for 7.4.6
Took 0.0007414 seconds per execution Took 0.0006161 seconds per execution
Output for 7.4.5
Took 0.0007632 seconds per execution Took 0.0006584 seconds per execution
Output for 7.4.4
Took 0.0007375 seconds per execution Took 0.0006228 seconds per execution
Output for 7.4.3
Took 0.0007327 seconds per execution Took 0.0006179 seconds per execution
Output for 7.4.2
Took 0.0007316 seconds per execution Took 0.0006176 seconds per execution
Output for 7.4.1
Took 0.0007296 seconds per execution Took 0.0006233 seconds per execution
Output for 7.4.0
Took 0.0007299 seconds per execution Took 0.0006161 seconds per execution
Output for 7.3.33
Took 0.0007206 seconds per execution Took 0.0006173 seconds per execution
Output for 7.3.32
Took 0.0007335 seconds per execution Took 0.0006177 seconds per execution
Output for 7.3.31
Took 0.0007290 seconds per execution Took 0.0006164 seconds per execution
Output for 7.3.30
Took 0.0007218 seconds per execution Took 0.0006187 seconds per execution
Output for 7.3.29
Took 0.0007318 seconds per execution Took 0.0006265 seconds per execution
Output for 7.3.28
Took 0.0007422 seconds per execution Took 0.0006204 seconds per execution
Output for 7.3.27
Took 0.0007221 seconds per execution Took 0.0006204 seconds per execution
Output for 7.3.26
Took 0.0007322 seconds per execution Took 0.0006214 seconds per execution
Output for 7.3.25
Took 0.0007290 seconds per execution Took 0.0006191 seconds per execution
Output for 7.3.24
Took 0.0007269 seconds per execution Took 0.0006269 seconds per execution
Output for 7.3.23
Took 0.0007255 seconds per execution Took 0.0006191 seconds per execution
Output for 7.3.22
Took 0.0007342 seconds per execution Took 0.0006256 seconds per execution
Output for 7.3.21
Took 0.0007321 seconds per execution Took 0.0006346 seconds per execution
Output for 7.3.20
Took 0.0007338 seconds per execution Took 0.0006184 seconds per execution
Output for 7.3.19
Took 0.0007282 seconds per execution Took 0.0006185 seconds per execution
Output for 7.3.18
Took 0.0007256 seconds per execution Took 0.0006218 seconds per execution
Output for 7.3.17
Took 0.0007184 seconds per execution Took 0.0006185 seconds per execution
Output for 7.3.16
Took 0.0007238 seconds per execution Took 0.0006177 seconds per execution
Output for 7.3.15
Took 0.0007320 seconds per execution Took 0.0006193 seconds per execution
Output for 7.3.14
Took 0.0007227 seconds per execution Took 0.0006143 seconds per execution
Output for 7.3.13
Took 0.0007277 seconds per execution Took 0.0006218 seconds per execution

preferences:
58.98 ms | 495 KiB | 5 Q