3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPairs($array) { $n = count($array); $keys = array_keys($array); $finalArray = []; $i = 0; foreach ($array as $a) { for ($x = $n-1; $i < $x; $x--) { $key1 = $keys[$i]; $key2 = $keys[$x]; $finalArray[$key1.$key2] = [$array[$key1], $array[$key2]]; } $i++; } return $finalArray; } $arr1 = 'arr1'; $arr2 = 'arr2'; $arr3 = 'arr3'; $merged = [ 'a'=> $arr1, 'b'=> $arr2, 'c'=> $arr3 ]; $pairs = getPairs($merged); print_r($pairs);

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.0080.00018.57
8.3.120.0130.00718.74
8.3.110.0000.01020.94
8.3.100.0060.00324.06
8.3.90.0070.00326.77
8.3.80.0030.00618.43
8.3.70.0110.01116.75
8.3.60.0070.01016.75
8.3.50.0110.00922.12
8.3.40.0070.01119.02
8.3.30.0110.00318.66
8.3.20.0040.00420.38
8.3.10.0080.00021.79
8.3.00.0050.00322.43
8.2.250.0120.00616.52
8.2.240.0000.00817.05
8.2.230.0060.00322.58
8.2.220.0060.00337.54
8.2.210.0070.00026.77
8.2.200.0080.00316.75
8.2.190.0070.00716.88
8.2.180.0060.00918.17
8.2.170.0070.00722.96
8.2.160.0170.00321.02
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0080.00019.82
8.2.110.0080.00322.26
8.2.100.0040.00817.68
8.2.90.0040.00418.34
8.2.80.0080.00020.53
8.2.70.0000.00818.16
8.2.60.0050.00318.03
8.2.50.0000.00918.07
8.2.40.0070.00318.16
8.2.30.0000.00818.00
8.2.20.0040.00417.72
8.2.10.0070.00018.03
8.2.00.0000.00817.78
8.1.300.0060.00317.97
8.1.290.0060.00330.84
8.1.280.0090.00625.92
8.1.270.0030.00624.03
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0100.00021.04
8.1.230.0090.00320.89
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0030.00717.35
8.1.190.0050.00317.35
8.1.180.0040.00418.10
8.1.170.0070.00318.48
8.1.160.0040.00418.84
8.1.150.0040.00418.77
8.1.140.0040.00419.57
8.1.130.0050.00219.23
8.1.120.0030.00417.46
8.1.110.0000.00717.34
8.1.100.0040.00417.44
8.1.90.0050.00217.51
8.1.80.0040.00417.50
8.1.70.0000.00717.46
8.1.60.0000.00817.48
8.1.50.0060.00317.45
8.1.40.0040.00417.44
8.1.30.0000.00917.55
8.1.20.0000.00717.66
8.1.10.0070.00017.53
8.1.00.0000.00817.53
8.0.300.0040.00420.03
8.0.290.0040.00416.63
8.0.280.0040.00418.31
8.0.270.0000.00716.73
8.0.260.0000.00616.82
8.0.250.0030.00316.91
8.0.240.0070.00016.84
8.0.230.0000.00716.95
8.0.220.0080.00016.90
8.0.210.0000.00716.90
8.0.200.0030.00316.90
8.0.190.0000.00916.89
8.0.180.0000.00716.95
8.0.170.0030.00616.80
8.0.160.0070.00016.95
8.0.150.0000.00816.80
8.0.140.0070.00016.76
8.0.130.0070.00013.27
8.0.120.0060.00316.89
8.0.110.0070.00016.76
8.0.100.0000.00717.00
8.0.90.0000.00716.71
8.0.80.0060.00916.85
8.0.70.0040.00416.68
8.0.60.0030.00516.70
8.0.50.0070.00016.86
8.0.30.0120.00717.10
8.0.20.0110.00917.40
8.0.10.0000.00717.06
8.0.00.0090.00916.81
7.4.330.0020.00215.09
7.4.320.0000.00616.48
7.4.300.0000.00616.51
7.4.290.0040.00416.57
7.4.280.0030.00616.63
7.4.270.0000.00916.48
7.4.260.0030.00316.46
7.4.250.0000.00816.46
7.4.240.0040.00416.43
7.4.230.0000.00716.42
7.4.220.0090.00916.48
7.4.210.0150.00016.67
7.4.200.0020.00516.62
7.4.160.0110.00916.42
7.4.150.0100.01417.40
7.4.140.0100.00817.86
7.4.130.0130.00616.57
7.4.120.0090.01016.50
7.4.110.0020.01516.45
7.4.100.0070.01016.37
7.4.90.0110.00816.35
7.4.80.0110.01117.90
7.4.70.0130.00616.36
7.4.60.0050.01416.27
7.4.50.0110.00516.48
7.4.40.0100.01116.55
7.4.30.0120.00516.39
7.4.20.0090.01216.52
7.4.10.0120.00916.24
7.4.00.0070.01015.79
7.3.330.0020.00513.38
7.3.320.0000.00613.45
7.3.310.0040.00416.42
7.3.300.0030.00316.23
7.3.290.0080.00816.37
7.3.280.0090.00916.35
7.3.270.0120.00617.40
7.3.260.0090.01116.41
7.3.250.0070.01216.33
7.3.240.0070.01016.59
7.3.230.0100.00716.51
7.3.220.0060.01116.28
7.3.210.0130.00816.40
7.3.200.0060.01416.44
7.3.190.0120.00716.43
7.3.180.0140.00516.44
7.3.170.0100.00916.46
7.3.160.0100.00916.44
7.3.150.0070.01116.41
7.3.140.0090.00916.26
7.3.130.0130.00516.27
7.3.120.0170.00016.38
7.3.110.0040.01516.33
7.3.100.0130.00616.17
7.3.90.0110.00716.32
7.3.80.0080.01116.29
7.3.70.0100.01216.28
7.3.60.0130.01016.34
7.3.50.0150.00416.35
7.3.40.0150.00316.53
7.3.30.0110.00616.20
7.3.20.0030.01616.26
7.3.10.0560.00616.32
7.3.00.0090.00916.30
7.2.340.0120.00616.50
7.2.330.0160.01116.75
7.2.320.0170.01216.52
7.2.310.0230.00616.71
7.2.300.0150.01016.64
7.2.290.0170.01016.63
7.2.280.0270.01116.52
7.2.270.0380.00016.66
7.2.260.0300.00316.52
7.2.250.0270.00616.52
7.2.240.0310.00316.52
7.2.230.0240.01216.42
7.2.220.0240.01016.41
7.2.210.0220.01016.37
7.2.200.0320.00416.59
7.2.190.0230.01316.63
7.2.180.0300.00716.61
7.2.170.0210.01016.50
7.2.160.0200.01216.57
7.2.150.0280.00716.74
7.2.140.0250.01116.79
7.2.130.0220.01616.58
7.2.120.0310.00616.55
7.2.110.0320.00716.59
7.2.100.0370.00916.65
7.2.90.0250.01416.58
7.2.80.0250.01116.63
7.2.70.0420.01416.70
7.2.60.0210.00616.80
7.2.50.0250.01316.61
7.2.40.0220.01016.63
7.2.30.0310.00716.72
7.2.20.0250.01316.76
7.2.10.0240.01416.60
7.2.00.0120.01218.06
7.1.330.0230.00815.76
7.1.320.0230.01015.57
7.1.310.0180.01915.48
7.1.300.0220.00715.65
7.1.290.0120.02115.63
7.1.280.0210.00915.57
7.1.270.0220.00815.60
7.1.260.0170.01615.54
7.1.250.0230.00915.71
7.1.240.0260.00315.66
7.1.230.0210.01815.59
7.1.220.0300.00615.65
7.1.210.0280.00815.48
7.1.200.0150.01015.62
7.1.190.0250.00715.42
7.1.180.0220.00715.58
7.1.170.0320.00515.66
7.1.160.0250.00715.57
7.1.150.0240.01215.61
7.1.140.0170.01715.61
7.1.130.0230.01015.57
7.1.120.0280.01115.62
7.1.110.0340.00015.64
7.1.100.0340.00415.61
7.1.90.0170.01715.48
7.1.80.0240.00715.61
7.1.70.0170.00516.34
7.1.60.0100.01216.31
7.1.50.0240.00715.65
7.1.40.0270.00315.55
7.1.30.0210.01015.53
7.1.20.0260.00415.49
7.1.10.0270.00915.73
7.1.00.0230.03819.04
7.0.330.0320.00315.16
7.0.320.0310.01215.39
7.0.310.0210.01515.13
7.0.300.0230.01115.32
7.0.290.0250.00715.14
7.0.280.0240.00915.15
7.0.270.0280.01115.21
7.0.260.0220.01115.31
7.0.250.0530.01715.24
7.0.240.0320.00315.30
7.0.230.0240.01015.36
7.0.220.0230.01015.19
7.0.210.0240.01415.28
7.0.200.0180.00515.20
7.0.190.0230.00715.18
7.0.180.0380.00315.28
7.0.170.0250.00815.29
7.0.160.0220.01015.17
7.0.150.0330.00015.16
7.0.140.0320.00315.33
7.0.130.0270.01415.29
7.0.120.0200.01215.23
7.0.110.0260.00915.37
7.0.100.0240.03317.75
7.0.90.0230.03117.68
7.0.80.0210.03417.64
7.0.70.0190.03317.53
7.0.60.0190.03117.71
7.0.50.0210.03017.86
7.0.40.0200.03217.81
7.0.30.0150.03717.77
7.0.20.0260.03117.81
7.0.10.0170.03117.79
7.0.00.0160.03617.82
5.6.400.0170.01716.10
5.6.390.0270.00916.05
5.6.380.0250.01215.95
5.6.370.0290.00316.13
5.6.360.0240.01216.14
5.6.350.0300.00716.36
5.6.340.0270.00516.14
5.6.330.0250.01416.21
5.6.320.0280.01115.98
5.6.310.0210.01216.26
5.6.300.0240.00816.11
5.6.290.0240.00816.14
5.6.280.0320.00315.82
5.6.270.0300.00816.17
5.6.260.0240.01115.94
5.6.250.0180.03618.44
5.6.240.0210.03718.35
5.6.230.0170.04018.29
5.6.220.0230.03018.36
5.6.210.0120.03818.33
5.6.200.0240.03018.72
5.6.190.0140.03718.53
5.6.180.0150.03418.54
5.6.170.0180.03418.47
5.6.160.0200.03318.51
5.6.150.0170.03418.53
5.6.140.0200.03318.66
5.6.130.0110.04418.62
5.6.120.0260.03318.52
5.6.110.0280.03018.52
5.6.100.0230.03318.73
5.6.90.0170.03818.37
5.6.80.0180.03818.13
5.6.70.0260.03518.18
5.6.60.0190.04518.21
5.6.50.0260.03218.26
5.6.40.0150.03818.20
5.6.30.0190.03518.14
5.6.20.0160.03718.28
5.6.10.0140.03318.18
5.6.00.0120.03818.23

preferences:
39.58 ms | 403 KiB | 5 Q