у меня была истерика когда я это увидел и услышал
надеюсь не баян
надеюсь не баян
User
$start = microtime(true);
$res1 = array();
for ($i = 0; $i < 1000; $i++) {
$res1 = array_merge($res1, array(1, 2, 3));
}
echo "1000 merges: " . ceil((microtime(true) - $start) * 1000) . "ms\n";
$start = microtime(true);
$toMerge = array();
for ($i = 0; $i < 1000; $i++) {
$toMerge[] = array(1, 2, 3);
}
$res2 = call_user_func_array('array_merge', $toMerge);
echo "call_user_func_array('array_merge',..): " . ceil((microtime(true) - $start) * 1000) . "ms\n";
echo "Is it true that the two arrays are equal? It is ";
var_export($res2 === $res1);
echo ".\n";
~ % php ~/tmp/array_merge.php
1000 merges: 980ms
call_user_func_array('array_merge',..): 11ms
Is it true that the two arrays are equal? It is true.