3v4l.org

run code in 300+ PHP versions simultaneously
<?php function chained(iterable ...$input): Generator { foreach ($input as $iterable) { yield from $iterable; } } echo "The \"chained\" iterable contains all elements, using a generator: "; foreach(chained( [1,2,3], [4,5], ) as $item){ echo "$item "; } echo "\n\n"; echo "However, when it comes to converting the generator to array, there is a caveat:\n"; $numbers = chained( [1,2,3], [4,5], ); print_r( iterator_to_array($numbers) ); echo "\n"; echo "The issue is caused by overlapping keys. See how they appear in the sequence:\n"; foreach(chained( [1,2,3], [4,5], ) as $key => $item){ echo "[$key] => $item\n"; } echo "\n\n"; echo "The issue is not present when the keys do not overlap:\n"; $numbers = chained( [1,2,3], [10 => 4,5], ); print_r( iterator_to_array($numbers) );

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.110.0050.00520.94
8.3.100.0150.00316.38
8.3.90.0070.00426.77
8.3.80.0200.00026.77
8.3.70.0160.00626.77
8.3.60.0080.00326.77
8.3.50.0040.00726.77
8.3.40.0090.01226.77
8.3.30.0060.00626.77
8.3.20.0100.00026.77
8.3.10.0120.00226.77
8.3.00.0050.00526.77
8.2.230.0110.00022.58
8.2.220.0090.00624.06
8.2.210.0070.00526.77
8.2.200.0000.01126.77
8.2.190.0060.00626.77
8.2.180.0060.00626.77
8.2.170.0110.00026.77
8.2.160.0050.00526.77
8.2.150.0040.00926.77
8.2.140.0030.00626.77
8.2.130.0040.00726.77
8.2.120.0070.00326.77
8.2.110.0100.00026.77
8.2.100.0070.00326.77
8.2.90.0060.00326.77
8.2.80.0100.00226.77
8.2.70.0090.00326.77
8.2.60.0140.00026.77
8.2.50.0110.00426.77
8.2.40.0070.00426.77
8.2.30.0080.00426.77
8.2.20.0040.00726.77
8.2.10.0090.00326.77
8.2.00.0110.00326.77
8.1.290.0120.00026.77
8.1.280.0060.00626.77
8.1.270.0070.00326.77
8.1.260.0040.00826.77
8.1.250.0110.00026.77
8.1.240.0100.00026.77
8.1.230.0040.00726.77
8.1.220.0100.00026.77
8.1.210.0030.00626.77
8.1.200.0070.00326.77
8.1.190.0040.00726.77
8.1.180.0070.00326.77
8.1.170.0090.00426.77
8.1.160.0040.00726.77
8.1.150.0090.00326.77
8.1.140.0160.00026.77
8.1.130.0090.00926.77
8.1.120.0170.00026.77
8.1.110.0130.00326.77
8.1.100.0160.00026.77
8.1.90.0110.00626.77
8.1.80.0110.00626.77
8.1.70.0100.00726.77
8.1.60.0130.00526.77
8.1.50.0090.00926.77
8.1.40.0190.00026.77
8.1.30.0140.00326.77
8.1.20.0100.00726.77
8.1.10.0160.00326.77
8.1.00.0160.00326.77

preferences:
36.26 ms | 403 KiB | 5 Q