3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ['a' => 'a', 'b' => 'b', 'c'=> 'c', 'd'=>'d', 'e'=>'e', 'f'=>'f'], ]; $iterations = 1000; $start = microtime(true); for ($i=0 ; $i<$iterations ; $i++) { $reduced = array_reduce($items, fn($carry, $scope_items) => [...$carry, ...array_values($scope_items)], []); } $split = microtime(true); for ($i=0 ; $i<$iterations ; $i++) { $item_sets = []; foreach ($items as $scope_items) { $item_sets[] = array_values($scope_items); } $looped = array_merge(...$item_sets); } $end = microtime(TRUE); echo "Reduce: " . ($split-$start)/$iterations . " sec\n"; echo "Merge: " . ($end-$split)/$iterations . " sec\n";

preferences:
37.13 ms | 407 KiB | 5 Q