<?php
$array = [
[1, 'xxx', 'yyy'],
[2, 'xxx', 'yyy'],
[3, 'xxx', 'yyy'],
[4, 'xxx', 'yyy'],
[5, 'xxx', 'yyy'],
[6, 'xxx', 'yyy'],
[7, 'xxx', 'yyy'],
[8, 'xxx', 'yyy'],
[9, 'xxx', 'yyy'],
[10, 'xxx', 'yyy'],
[11, 'xxx', 'yyy'],
[12, 'xxx', 'yyy'],
[13, 'xxx', 'yyy'],
[14, 'xxx', 'yyy'],
[15, 'xxx', 'yyy'],
[16, 'xxx', 'yyy'],
[17, 'xxx', 'yyy'],
[18, 'xxx', 'yyy'],
[19, 'xxx', 'yyy'],
[1, 'xxx', 'yyy'],
[2, 'xxx', 'yyy'],
[3, 'xxx', 'yyy'],
[4, 'xxx', 'yyy'],
[5, 'xxx', 'yyy'],
[6, 'xxx', 'yyy'],
[7, 'xxx', 'yyy'],
[8, 'xxx', 'yyy'],
[9, 'xxx', 'yyy'],
[10, 'xxx', 'yyy'],
[11, 'xxx', 'yyy'],
[12, 'xxx', 'yyy'],
[13, 'xxx', 'yyy'],
[14, 'xxx', 'yyy'],
[15, 'xxx', 'yyy'],
[16, 'xxx', 'yyy'],
[17, 'xxx', 'yyy'],
[18, 'xxx', 'yyy'],
[19, 'xxx', 'yyy']
];
$t = microtime(true);
$result = array_map(function($v){ return $v[0]; }, $array);
echo number_format(microtime(true) - $t, 3), PHP_EOL;
$t = microtime(true);
$result = array();
foreach($array as $v)$result[] = $v[0];
echo number_format(microtime(true) - $t, 3), PHP_EOL;
?>
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.14, 7.4.18 - 7.4.33, 8.0.1 - 8.0.25, 8.1.0 - 8.1.20, 8.1.22, 8.2.0 - 8.2.9
- 0.000
0.000
- Output for 8.1.21
- 0.003
0.000
- Output for 8.0.26 - 8.0.30
- 0.001
0.000
- Output for 7.4.15 - 7.4.16, 8.0.0
- 0.000
0.001
- Output for 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected '[' in /in/XgtZu on line 2
Process exited with code 255.
preferences:
196.07 ms | 401 KiB | 393 Q