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\" 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.130.0060.00318.45
8.3.120.0100.00019.08
8.3.110.0340.01016.21
8.3.100.0370.01016.50
8.3.90.0420.00616.24
8.3.80.0420.00616.42
8.3.70.0330.01316.23
8.3.60.0380.00916.40
8.3.50.0410.00616.23
8.3.40.0250.01417.40
8.3.30.0240.01617.21
8.3.20.0300.00917.34
8.3.10.0270.01517.38
8.3.00.0150.00817.25
8.2.250.0040.00418.65
8.2.240.0090.00919.13
8.2.230.0320.01116.59
8.2.220.0230.00916.35
8.2.210.0330.00016.40
8.2.200.0270.01016.24
8.2.190.0360.00416.65
8.2.180.0360.00616.47
8.2.170.0350.01417.32
8.2.160.0350.00317.47
8.2.150.0390.00317.72
8.2.140.0310.00817.50
8.2.130.0360.00617.15
8.2.120.0270.01517.41
8.2.110.0220.01517.39
8.2.100.0310.01117.34
8.2.90.0540.00817.53
8.2.80.0370.00617.30
8.2.70.0360.00717.47
8.2.60.0400.00017.52
8.2.50.0330.00717.38
8.2.40.0350.00717.15
8.2.30.0280.01217.08
8.2.20.0170.00817.38
8.2.10.0130.00717.56
8.2.00.0270.00317.35
8.1.300.0140.00418.01
8.1.290.0150.00416.26
8.1.280.0220.00316.32
8.1.270.0320.00317.41
8.1.260.0380.00317.38
8.1.250.0310.01017.14
8.1.240.0290.00917.00
8.1.230.0320.00617.19
8.1.220.0250.01117.29
8.1.210.0280.00317.09
8.1.200.0250.01517.17
8.1.190.0340.00316.95
8.1.180.0240.01417.01
8.1.170.0380.00016.93
8.1.160.0270.00616.97
8.1.150.0300.00717.04
8.1.140.0250.01217.14
8.1.130.0220.01517.24
8.1.120.0210.00917.28
8.1.110.0340.00317.26
8.1.100.0330.00317.27
8.1.90.0300.01117.05
8.1.80.0240.00717.38
8.1.70.0260.00717.24
8.1.60.0260.01517.25
8.1.50.0370.00417.36
8.1.40.0310.01017.38
8.1.30.0330.00817.45
8.1.20.0200.02017.48
8.1.10.0290.00617.54
8.1.00.0300.00317.26

preferences:
26.44 ms | 403 KiB | 5 Q