3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( 'parent_id' => array ( 9 => array ( 0 => 12 ), 20 => array ( 0 => 25, 1 => 22 ), 21 => array ( 0 => 23, 1 => 24 ) ) ); // re-index to 0 $array = array_values($array['parent_id']); // sort so the longest arrays are first usort($array, function ($a, $b) { return count($b) - count($a); }); // output array $pairs = array(); for ($i = 0; $i < count($array) - 1; $i += 2) { for ($j = 0; $j < min(count($array[$i]), count($array[$i+1])); $j++) { $pairs[] = array($array[$i][$j], $array[$i+1][$j]); } } 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.4.130.0130.00717.81
8.4.120.0120.00920.47
8.4.110.0150.00622.58
8.4.100.0060.00318.03
8.4.90.0110.00818.62
8.4.80.0050.00417.81
8.4.70.0110.00817.68
8.4.60.0050.00318.80
8.4.50.0130.00520.48
8.4.40.0080.01219.51
8.4.30.0090.00017.71
8.4.20.0130.00620.56
8.4.10.0060.00317.50
8.3.260.0150.00516.65
8.3.250.0130.00618.98
8.3.240.0140.00516.69
8.3.230.0080.01116.66
8.3.220.0090.00916.95
8.3.210.0100.00416.86
8.3.200.0030.00616.81
8.3.190.0100.00818.87
8.3.180.0120.00716.93
8.3.170.0160.00317.21
8.3.160.0030.00716.89
8.3.150.0090.00916.82
8.3.140.0150.00318.50
8.3.130.0090.00918.55
8.3.120.0030.00618.80
8.3.110.0070.00320.94
8.3.100.0100.00024.06
8.3.90.0000.00826.77
8.3.80.0060.00318.67
8.3.70.0120.00616.60
8.3.60.0110.00418.56
8.3.50.0100.00520.24
8.3.40.0090.01318.68
8.3.30.0140.00018.81
8.3.20.0050.00320.84
8.3.10.0040.00421.52
8.3.00.0040.00421.63
8.2.290.0110.00720.50
8.2.280.0060.01018.26
8.2.270.0100.01017.34
8.2.260.0090.00618.98
8.2.250.0000.00918.37
8.2.240.0160.00319.07
8.2.230.0040.00722.58
8.2.220.0090.00937.54
8.2.210.0040.00426.77
8.2.200.0030.00618.54
8.2.190.0120.00616.58
8.2.180.0120.00416.88
8.2.170.0070.00722.96
8.2.160.0120.00320.57
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0100.00019.89
8.2.120.0080.00026.35
8.2.110.0060.00322.06
8.2.100.0060.00619.39
8.2.90.0040.00417.88
8.2.80.0040.00418.82
8.2.70.0040.00417.50
8.2.60.0060.00317.93
8.2.50.0050.00318.07
8.2.40.0080.00018.34
8.2.30.0040.00418.19
8.2.20.0000.00718.22
8.2.10.0000.00719.41
8.2.00.0040.00418.01
8.1.330.0060.00421.88
8.1.320.0100.00816.23
8.1.310.0070.00718.67
8.1.300.0060.00318.23
8.1.290.0060.00330.84
8.1.280.0110.00425.92
8.1.270.0030.00621.95
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0060.00320.65
8.1.230.0090.00317.86
8.1.220.0040.00417.74
8.1.210.0070.00318.77
8.1.200.0030.00617.35
8.1.190.0000.00917.47
8.1.180.0060.00318.10
8.1.170.0030.00518.72
8.1.160.0000.00718.93
8.1.150.0000.00718.80
8.1.140.0040.00418.93
8.1.130.0070.00020.10
8.1.120.0060.00317.48
8.1.110.0000.00717.41
8.1.100.0040.00417.46
8.1.90.0040.00417.39
8.1.80.0040.00717.40
8.1.70.0070.00017.40
8.1.60.0000.00917.66
8.1.50.0000.00717.45
8.1.40.0000.00817.44
8.1.30.0000.01117.52
8.1.20.0000.01017.73
8.1.10.0060.00317.50
8.1.00.0040.00417.59
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0080.00018.43
8.0.270.0040.00417.20
8.0.260.0000.00918.39
8.0.250.0000.00916.95
8.0.240.0070.00017.00
8.0.230.0000.00816.95
8.0.220.0000.00816.98
8.0.210.0000.00716.88
8.0.200.0040.00416.89
8.0.190.0060.00316.97
8.0.180.0040.00416.94
8.0.170.0080.00016.95
8.0.160.0070.00016.88
8.0.150.0040.00416.88
8.0.140.0000.00716.78
8.0.130.0000.00813.36
8.0.120.0040.00416.82
8.0.110.0040.00416.72
8.0.100.0070.00016.99
8.0.90.0050.00316.81
8.0.80.0070.01116.93
8.0.70.0070.00016.91
8.0.60.0000.00817.04
8.0.50.0070.00016.70
8.0.30.0150.00317.38
8.0.20.0290.02017.17
8.0.10.0070.00016.89
8.0.00.0100.00716.83
7.4.330.0020.00216.82
7.4.320.0030.00316.61
7.4.300.0030.00316.53
7.4.290.0060.00316.64
7.4.280.0030.00516.45
7.4.270.0030.00516.54
7.4.260.0030.00316.59
7.4.250.0030.00316.59
7.4.240.0000.00716.55
7.4.230.0080.00016.66
7.4.220.0040.00416.64
7.4.210.0040.01216.56
7.4.200.0070.00016.56
7.4.160.0080.01016.56
7.4.140.0090.00917.86
7.4.130.0120.00616.49
7.4.120.0150.00916.54
7.4.110.0130.00316.32
7.4.100.0130.00316.61
7.4.90.0140.00316.67
7.4.80.0070.01019.39
7.4.70.0070.01016.64
7.4.60.0060.01116.55
7.4.50.0030.01216.52
7.4.40.0120.00816.45
7.4.00.0070.00414.88
7.3.330.0000.00513.22
7.3.320.0000.00613.39
7.3.310.0000.00716.24
7.3.300.0030.00316.30
7.3.290.0100.00816.30
7.3.280.0080.01016.25
7.3.260.0090.01116.38
7.3.240.0070.01016.46
7.3.230.0090.00616.43
7.3.210.0130.00316.66
7.3.200.0150.00616.28
7.3.190.0060.00916.57
7.3.180.0090.00816.53
7.3.170.0030.01416.38
7.3.160.0030.01316.59
7.3.40.0020.00914.34
7.3.30.0100.00314.25
7.3.20.0030.01016.06
7.3.10.0000.01016.22
7.3.00.0070.00416.61
7.2.330.0000.01716.72
7.2.320.0140.01016.43
7.2.310.0170.00016.59
7.2.300.0060.01816.58
7.2.290.0090.01416.85
7.2.170.0130.01014.77
7.2.160.0070.00714.50
7.2.150.0060.00616.44
7.2.140.0110.01116.60
7.2.130.0100.01016.57
7.2.120.0090.01316.82
7.2.110.0060.00616.98
7.2.100.0030.00816.84
7.2.90.0030.01316.45
7.2.80.0160.00716.89
7.2.70.0190.00316.74
7.2.60.0030.01316.84
7.2.50.0120.00016.72
7.2.40.0110.00016.77
7.2.30.0060.00916.82
7.2.20.0070.00716.54
7.2.10.0130.00016.97
7.2.00.0050.00816.59
7.1.280.0070.00615.66
7.1.270.0000.01215.50
7.1.260.0080.00415.45
7.1.250.0030.00715.18

preferences:
32.15 ms | 403 KiB | 5 Q