- var_dump: documentation ( source)
- microtime: documentation ( source)
- array_merge: documentation ( source)
- range: documentation ( source)
$elapsed = microtime(true) - $start;
var_dump($elapsed);
$elapsed = microtime(true) - $start;
var_dump($elapsed);
<?php
$a = range(0, 250_000);
$b = range(250_000, 500_000);
$start = microtime(true);
foreach(array_merge($a, $b) as $key => $item){
//
}
$elapsed = microtime(true) - $start;
var_dump($elapsed);
$gen = function(array ...$input):iterable{foreach($input as $it) {yield from $it;}};
$start = microtime(true);
foreach($gen($a, $b) as $key => $item){
//
}
$elapsed = microtime(true) - $start;
var_dump($elapsed);