<?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']
];
$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.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
- 0.000
0.000
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected '[' in /in/v5vWN on line 2
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '[' in /in/v5vWN on line 2
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/v5vWN on line 2
Process exited with code 255.
preferences:
152.39 ms | 401 KiB | 215 Q