3v4l.org

run code in 300+ PHP versions simultaneously
<?php $src = ["apple", "cherry", "grape", "lemon", "orange", "strawberry", "cherry", "cherry"]; $dst = ["apple", "banana", "cherry", "orange", "pear", "cherry"]; $result = []; while ($src && $dst) { if ($src[0] === $dst[0]) { // align identical values $result[] = [array_shift($src), array_shift($dst)]; continue; } $earliestSrcMatch = array_search($src[0], $dst); $earliestDstMatch = array_search($dst[0], $src); if ($earliestSrcMatch === $earliestDstMatch) { //both false (not 0) $result[] = [array_shift($src), null]; $result[] = [null, array_shift($dst)]; continue; } elseif ( $earliestDstMatch === false || ( $earliestSrcMatch !== false && $earliestSrcMatch < $earliestDstMatch ) ) { while ($dst && $src[0] !== $dst[0]) { $result[] = [null, array_shift($dst)]; } } elseif ( $earliestSrcMatch === false || $earliestSrcMatch > $earliestDstMatch ) { while ($src && $src[0] !== $dst[0]) { $result[] = [array_shift($src), null]; } } } while ($src) { $result[] = [array_shift($src), null]; } while ($dst) { $result[] = [null, array_shift($dst)]; } echo "<table border=1> "; foreach ($result as $i => [$s, $d]) { printf( "<tr> <td>%d</td> <td>%s</td> <td>%s</td> </tr>\n", ++$i, $s, $d ); } echo "</table>";

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.5.10.0060.01220.27
8.5.00.0110.01019.99
8.4.160.0130.00823.96
8.4.150.0090.00516.83
8.4.140.0110.01017.53
8.4.130.0060.00418.73
8.4.120.0130.00524.25
8.4.110.0160.00518.80
8.4.100.0110.00818.89
8.4.90.0120.00620.38
8.4.80.0100.00317.64
8.4.70.0080.00418.09
8.4.60.0090.01018.64
8.4.50.0030.00717.98
8.4.40.0130.00617.50
8.4.30.0100.01018.71
8.4.20.0070.01322.33
8.4.10.0130.00723.74
8.3.280.0110.00920.90
8.3.270.0120.01016.40
8.3.260.0120.00416.49
8.3.250.0080.01019.04
8.3.240.0150.00417.49
8.3.230.0120.00816.45
8.3.220.0100.00819.06
8.3.210.0060.01116.86
8.3.200.0050.00316.86
8.3.190.0090.01017.27
8.3.180.0080.01116.56
8.3.170.0070.01118.72
8.3.160.0100.01018.54
8.3.150.0100.01017.29
8.3.140.0110.00719.21
8.3.130.0030.00618.41
8.3.120.0000.00820.65
8.3.110.0130.00317.00
8.3.100.0070.00324.06
8.3.90.0040.00426.77
8.3.80.0090.00018.43
8.3.70.0090.01316.58
8.3.60.0090.00916.63
8.3.50.0070.00720.07
8.3.40.0130.00320.41
8.3.30.0130.00621.52
8.3.20.0030.00624.18
8.3.10.0040.00424.66
8.3.00.0000.00826.16
8.2.290.0120.00720.30
8.2.280.0120.00818.51
8.2.270.0150.00316.39
8.2.260.0060.00318.94
8.2.250.0040.01518.17
8.2.240.0000.00917.45
8.2.230.0030.00620.94
8.2.220.0160.00437.54
8.2.210.0040.01126.77
8.2.200.0060.00318.54
8.2.190.0110.00418.16
8.2.180.0070.01125.92
8.2.170.0080.00818.91
8.2.160.0100.00322.96
8.2.150.0070.00025.66
8.2.140.0060.00924.66
8.2.130.0050.00326.16
8.2.120.0060.00326.16
8.2.110.0100.00021.11
8.2.100.0060.00617.91
8.2.90.0080.00018.28
8.2.80.0050.00318.20
8.2.70.0030.00517.63
8.2.60.0000.00917.63
8.2.50.0030.00618.05
8.2.40.0050.00518.85
8.2.30.0050.00817.91
8.2.20.0040.00918.43
8.2.10.0080.00517.92
8.2.00.0030.00518.50
8.1.330.0120.00822.18
8.1.320.0110.00916.26
8.1.310.0050.00316.67
8.1.300.0080.00019.96
8.1.290.0060.00330.84
8.1.280.0000.01525.92
8.1.270.0040.00424.66
8.1.260.0060.00326.35
8.1.250.0030.00528.09
8.1.240.0080.00323.76
8.1.230.0090.00320.91
8.1.220.0040.00417.76
8.1.210.0030.00518.77
8.1.200.0080.00017.23
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0010.00718.38
8.1.160.0070.00518.27
8.1.150.0060.00618.09
8.1.140.0020.00617.50
8.1.130.0080.00418.31
8.1.120.0060.00717.52
8.1.110.0080.00417.57
8.1.100.0120.00517.49
8.1.90.0120.00317.56
8.1.80.0130.00317.49
8.1.70.0140.00317.55
8.1.60.0160.00117.60
8.1.50.0120.00517.52
8.1.40.0120.00517.52
8.1.30.0130.00417.47
8.1.20.0100.00617.48
8.1.10.0100.00117.49
8.1.00.0100.00517.44
8.0.300.0000.00820.01
8.0.290.0040.00416.63
8.0.280.0080.00418.06
8.0.270.0070.00517.44
8.0.260.0080.00318.00
8.0.250.0070.00517.28
8.0.240.0110.00517.25
8.0.230.0120.00317.14
8.0.220.0100.00417.24
8.0.210.0110.00317.25
8.0.200.0090.00517.31
8.0.190.0080.00717.30
8.0.180.0140.00217.28
8.0.170.0110.00517.26
8.0.160.0050.01117.25
8.0.150.0110.00517.14
8.0.140.0140.00117.27
8.0.130.0080.00617.27
8.0.120.0100.00517.22
8.0.110.0100.00617.25
8.0.100.0110.00417.26
8.0.90.0130.00317.20
8.0.80.0070.00917.27
8.0.70.0080.00817.16
8.0.60.0130.00417.26
8.0.50.0090.00717.17
8.0.30.0140.00217.27
8.0.20.0110.00417.25
8.0.10.0110.00417.36
7.4.330.0050.00516.58
7.4.320.0060.01017.11
7.4.300.0110.00417.07
7.4.290.0100.00417.10
7.4.280.0070.00717.05
7.4.270.0100.00617.08
7.4.260.0070.01017.08
7.4.250.0130.00417.10
7.4.240.0060.00817.10
7.4.230.0040.00917.05
7.4.220.0060.00616.98
7.4.210.0080.00517.08
7.4.200.0110.00216.99
7.4.190.0110.00317.05
7.4.180.0190.00017.11
7.4.160.0110.00617.04
7.4.150.0100.00617.08
7.4.140.0090.00617.06
7.4.130.0130.00217.08
7.4.120.0110.00417.05
7.4.110.0130.00216.99
7.4.100.0150.00017.09
7.4.90.0140.00117.06
7.4.80.0090.00617.06
7.4.70.0100.00417.05
7.4.60.0100.00417.03
7.4.50.0090.00516.95
7.4.40.0110.00417.06
7.4.30.0060.00817.00
7.4.20.0120.00216.96
7.4.10.0150.00017.06
7.4.00.0110.00217.02

preferences:
115.54 ms | 403 KiB | 5 Q