3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $entries = []; for($i = 0; $i < 100000; $i++) { $entries[] = ['id' => $i]; } $t = microtime(true); $res = array_map(function($entry) { return $entry['id']; }, $entries); $t = microtime(true) - $t; echo 'array_map() took ' . number_format($t, 3) . ' seconds'; $t = microtime(true); $res = []; foreach($entries as $entry) { $res[] = $entry['id']; } $t = microtime(true) - $t; echo "\n"; echo 'foreach took ' . number_format($t, 3) . ' seconds';
based on 1NoB0
Output for 7.0.14 - 7.1.0
array_map() took 0.013 seconds foreach took 0.011 seconds
Output for 7.0.1, 7.0.6
array_map() took 0.018 seconds foreach took 0.017 seconds
Output for 7.0.5
array_map() took 0.016 seconds foreach took 0.013 seconds
Output for 7.0.4
array_map() took 0.017 seconds foreach took 0.014 seconds
Output for 7.0.3
array_map() took 0.017 seconds foreach took 0.018 seconds
Output for 7.0.2
array_map() took 0.023 seconds foreach took 0.021 seconds
Output for 7.0.0
array_map() took 0.017 seconds foreach took 0.016 seconds
Output for 5.6.28
array_map() took 0.051 seconds foreach took 0.015 seconds
Output for 5.6.21
array_map() took 0.052 seconds foreach took 0.025 seconds
Output for 5.6.20
array_map() took 0.053 seconds foreach took 0.025 seconds
Output for 5.6.19
array_map() took 0.051 seconds foreach took 0.025 seconds
Output for 5.6.18
array_map() took 0.056 seconds foreach took 0.028 seconds
Output for 5.6.17
array_map() took 0.047 seconds foreach took 0.024 seconds
Output for 5.6.10, 5.6.12, 5.6.16
array_map() took 0.055 seconds foreach took 0.026 seconds
Output for 5.6.9, 5.6.15
array_map() took 0.049 seconds foreach took 0.025 seconds
Output for 5.6.14
array_map() took 0.071 seconds foreach took 0.032 seconds
Output for 5.6.13
array_map() took 0.057 seconds foreach took 0.026 seconds
Output for 5.6.11
array_map() took 0.062 seconds foreach took 0.031 seconds
Output for 5.6.8
array_map() took 0.050 seconds foreach took 0.025 seconds
Output for 5.6.7
array_map() took 0.049 seconds foreach took 0.024 seconds
Output for 5.5.35
array_map() took 0.050 seconds foreach took 0.024 seconds
Output for 5.5.34
array_map() took 0.051 seconds foreach took 0.026 seconds
Output for 5.5.33
array_map() took 0.057 seconds foreach took 0.027 seconds
Output for 5.5.32
array_map() took 0.049 seconds foreach took 0.026 seconds
Output for 5.5.31
array_map() took 0.045 seconds foreach took 0.024 seconds
Output for 5.5.30
array_map() took 0.053 seconds foreach took 0.027 seconds
Output for 5.5.29
array_map() took 0.061 seconds foreach took 0.028 seconds
Output for 5.5.28
array_map() took 0.043 seconds foreach took 0.023 seconds
Output for 5.5.27
array_map() took 0.054 seconds foreach took 0.026 seconds
Output for 5.4.2, 5.4.15, 5.5.26
array_map() took 0.060 seconds foreach took 0.031 seconds
Output for 5.5.25
array_map() took 0.056 seconds foreach took 0.027 seconds
Output for 5.4.6, 5.5.24
array_map() took 0.062 seconds foreach took 0.030 seconds
Output for 5.4.45
array_map() took 0.053 seconds foreach took 0.037 seconds
Output for 5.4.44
array_map() took 0.068 seconds foreach took 0.037 seconds
Output for 5.4.43
array_map() took 0.379 seconds foreach took 0.213 seconds
Output for 5.4.42
array_map() took 0.157 seconds foreach took 0.133 seconds
Output for 5.4.41
array_map() took 0.062 seconds foreach took 0.045 seconds
Output for 5.4.40
array_map() took 0.098 seconds foreach took 0.147 seconds
Output for 5.4.39
array_map() took 0.087 seconds foreach took 0.047 seconds
Output for 5.4.38
array_map() took 0.166 seconds foreach took 0.058 seconds
Output for 5.4.37
array_map() took 0.178 seconds foreach took 0.091 seconds
Output for 5.4.36
array_map() took 0.089 seconds foreach took 0.059 seconds
Output for 5.4.35
array_map() took 0.177 seconds foreach took 0.076 seconds
Output for 5.4.34
array_map() took 0.089 seconds foreach took 0.045 seconds
Output for 5.4.30, 5.4.32
array_map() took 0.054 seconds foreach took 0.027 seconds
Output for 5.4.24, 5.4.31
array_map() took 0.053 seconds foreach took 0.029 seconds
Output for 5.4.29
array_map() took 0.050 seconds foreach took 0.027 seconds
Output for 5.4.28
array_map() took 0.054 seconds foreach took 0.029 seconds
Output for 5.4.27
array_map() took 0.057 seconds foreach took 0.030 seconds
Output for 5.4.26
array_map() took 0.055 seconds foreach took 0.033 seconds
Output for 5.4.25
array_map() took 0.055 seconds foreach took 0.030 seconds
Output for 5.4.23
array_map() took 0.068 seconds foreach took 0.045 seconds
Output for 5.4.22
array_map() took 0.061 seconds foreach took 0.030 seconds
Output for 5.4.11, 5.4.21
array_map() took 0.056 seconds foreach took 0.030 seconds
Output for 5.4.20
array_map() took 0.051 seconds foreach took 0.027 seconds
Output for 5.4.19
array_map() took 0.053 seconds foreach took 0.028 seconds
Output for 5.4.7, 5.4.18
array_map() took 0.051 seconds foreach took 0.028 seconds
Output for 5.4.17
array_map() took 0.055 seconds foreach took 0.028 seconds
Output for 5.4.16
array_map() took 0.062 seconds foreach took 0.027 seconds
Output for 5.4.14
array_map() took 0.055 seconds foreach took 0.029 seconds
Output for 5.4.13
array_map() took 0.059 seconds foreach took 0.031 seconds
Output for 5.4.12
array_map() took 0.067 seconds foreach took 0.029 seconds
Output for 5.4.10
array_map() took 0.061 seconds foreach took 0.029 seconds
Output for 5.4.9
array_map() took 0.091 seconds foreach took 0.049 seconds
Output for 5.4.8
array_map() took 0.049 seconds foreach took 0.027 seconds
Output for 5.4.5
array_map() took 0.056 seconds foreach took 0.035 seconds
Output for 5.4.4
array_map() took 0.098 seconds foreach took 0.054 seconds
Output for 5.4.1, 5.4.3
array_map() took 0.054 seconds foreach took 0.030 seconds
Output for 5.4.0
array_map() took 0.059 seconds foreach took 0.033 seconds
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/MZnfH on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/MZnfH on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/MZnfH on line 3
Process exited with code 255.