3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 1,2,3,4 ]; $expected = [ '1-2-3-4', '2-1-3-4', '3-1-2-4', '1-3-2-4', '2-3-1-4', '3-2-1-4', '4-2-1-3', '2-4-1-3', '1-4-2-3', '4-1-2-3', '2-1-4-3', '1-2-4-3', '1-3-4-2', '3-1-4-2', '4-1-3-2', '1-4-3-2', '3-4-1-2', '4-3-1-2', '4-3-2-1', '3-4-2-1', '2-4-3-1', '4-2-3-1', '3-2-4-1', '2-3-4-1', ]; function mixture( $size, array &$collection ) { $permutations = []; $offset = $size - 1; if ( 1 === $size ) { $permutations[] = implode( '-', $collection ); return $permutations; } for ( $i = 0; $i < $offset; $i++ ) { $permutations = array_merge( $permutations, mixture( $offset, $collection ) ); $j = ( 0 == $size % 2 ) ? $i : 0; $tmp_el = $collection[ $offset ]; $collection[ $offset ] = $collection[ $j ]; $collection[ $j ] = $tmp_el; } $permutations = array_merge( $permutations, mixture( $offset, $collection ) ); return $permutations; } print_r($permutations = mixture( count($arr), $arr )); if ($expected == $permutations) { echo 'PASS'.PHP_EOL; } else { echo 'FAIL'.PHP_EOL; echo 'missing: '.PHP_EOL; print_r(array_diff($expected, array_unique($permutations))); }

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.80.0000.00918.55
8.3.70.0040.01118.27
8.3.60.0140.00416.63
8.3.50.0110.00817.37
8.3.40.0100.01018.93
8.3.30.0100.00718.67
8.3.20.0000.01521.81
8.3.10.0140.00421.72
8.3.00.0060.00319.65
8.2.200.0030.00718.29
8.2.190.0110.00816.58
8.2.180.0190.00318.25
8.2.170.0030.01022.96
8.2.160.0060.00920.50
8.2.150.0000.01024.18
8.2.140.0070.01124.66
8.2.130.0050.00320.57
8.2.120.0080.00026.35
8.2.110.0110.00020.99
8.2.100.0000.01120.33
8.2.90.0030.00719.41
8.2.80.0060.00318.16
8.2.70.0030.00617.93
8.2.60.0090.00018.16
8.2.50.0000.00918.10
8.2.40.0030.00522.32
8.2.30.0040.00421.00
8.2.20.0000.01018.11
8.2.10.0000.00818.13
8.2.00.0000.00818.12
8.1.290.0100.00030.84
8.1.280.0140.00725.92
8.1.270.0000.00820.70
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0070.00322.20
8.1.230.0070.00419.14
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0030.00617.25
8.1.190.0070.00317.09
8.1.180.0040.00818.10
8.1.170.0040.00418.50
8.1.160.0080.00019.00
8.1.150.0030.00520.59
8.1.140.0070.00019.68
8.1.130.0030.00318.90
8.1.120.0040.00417.50
8.1.110.0000.00917.44
8.1.100.0050.00217.50
8.1.90.0040.00417.36
8.1.80.0030.00317.36
8.1.70.0000.00817.37
8.1.60.0050.00317.57
8.1.50.0030.00617.46
8.1.40.0000.00817.40
8.1.30.0040.00417.64
8.1.20.0080.00017.68
8.1.10.0050.00217.62
8.1.00.0000.00717.55
8.0.300.0040.00419.57
8.0.290.0040.00416.75
8.0.280.0050.00318.43
8.0.270.0030.00317.27
8.0.260.0060.00018.93
8.0.250.0000.00717.09
8.0.240.0050.00317.02
8.0.230.0000.00716.99
8.0.220.0000.00716.87
8.0.210.0000.00716.87
8.0.200.0030.00317.06
8.0.190.0050.00517.01
8.0.180.0000.00717.02
8.0.170.0000.00817.00
8.0.160.0000.00717.08
8.0.150.0040.00416.88
8.0.140.0090.00316.81
8.0.130.0000.00613.39
8.0.120.0040.00416.85
8.0.110.0040.00417.05
8.0.100.0030.00617.02
8.0.90.0000.00716.94
8.0.80.0070.01616.91
8.0.70.0050.00216.89
8.0.60.0040.00416.84
8.0.50.0000.00716.79
8.0.30.0080.01217.30
8.0.20.0130.00817.40
8.0.10.0030.00517.13
8.0.00.0080.01217.02
7.4.330.0030.00315.55
7.4.320.0030.00316.65
7.4.300.0030.00316.46
7.4.290.0100.00016.52
7.4.280.0040.00416.61
7.4.270.0030.00516.65
7.4.260.0060.00316.64
7.4.250.0000.00716.46
7.4.240.0030.00316.50
7.4.230.0020.00516.35
7.4.220.0110.00716.54
7.4.210.0040.01116.55
7.4.200.0000.00716.63
7.4.160.0070.01016.39
7.4.150.0090.00917.40
7.4.140.0080.00917.86
7.4.130.0060.01316.55
7.4.120.0110.00816.47
7.4.110.0070.01016.45
7.4.100.0060.01316.52
7.4.90.0170.00016.39
7.4.80.0090.00919.39
7.4.70.0070.01016.56
7.4.60.0070.01016.50
7.4.50.0030.00916.48
7.4.40.0100.00716.68
7.4.30.0160.00316.52
7.4.00.0070.00714.64
7.3.330.0040.00413.34
7.3.320.0000.00513.38
7.3.310.0000.00716.34
7.3.300.0040.00416.38
7.3.290.0080.00816.32
7.3.280.0080.01016.31
7.3.270.0130.00717.40
7.3.260.0070.00916.59
7.3.250.0120.00616.40
7.3.240.0080.00816.48
7.3.230.0100.01316.41
7.3.210.0110.00716.50
7.3.200.0140.01016.23
7.3.190.0080.00816.27
7.3.180.0060.01016.38
7.3.170.0070.01016.38
7.3.160.0090.01516.27
7.3.120.0040.01114.87
7.3.110.0030.01014.52
7.3.100.0030.01014.71
7.3.90.0040.00415.15
7.3.80.0060.00914.79
7.3.70.0030.01314.80
7.3.60.0100.00715.03
7.3.50.0070.00714.74
7.3.40.0130.00314.84
7.3.30.0090.00314.77
7.3.20.0030.01016.48
7.3.10.0090.00616.47
7.3.00.0070.01116.54
7.2.330.0090.01216.61
7.2.320.0090.00916.84
7.2.310.0060.00916.80
7.2.300.0080.00816.63
7.2.290.0050.01216.85
7.2.240.0070.00415.34
7.2.230.0100.00014.94
7.2.220.0040.01115.10
7.2.210.0030.00715.24
7.2.200.0040.01115.14
7.2.190.0030.01015.14
7.2.180.0060.00615.09
7.2.170.0050.00515.11
7.2.160.0000.01015.29
7.2.150.0040.00816.84
7.2.140.0060.00916.97
7.2.130.0000.01117.00
7.2.120.0030.01217.02
7.2.110.0070.00716.83
7.2.100.0060.00917.05
7.2.90.0070.01017.06
7.2.80.0030.01016.96
7.2.70.0000.01616.92
7.2.60.0060.00917.10
7.2.50.0090.00616.79
7.2.40.0120.00017.03
7.2.30.0090.00616.89
7.2.20.0100.00716.78
7.2.10.0060.00616.91
7.2.00.0090.00616.69
7.1.330.0070.00715.90
7.1.320.0090.00315.87
7.1.310.0030.00915.95
7.1.300.0090.00315.85
7.1.290.0030.01215.72
7.1.280.0030.00815.71
7.1.270.0140.00015.77
7.1.260.0100.00015.86
7.1.250.0060.00915.84
7.1.200.0060.00615.75
7.1.70.0030.00817.07
7.1.60.0200.01335.24
7.1.50.0200.00734.72
7.1.40.0170.01334.48
7.1.30.0130.02034.55
7.1.20.0230.01334.32
7.1.10.0000.01316.64
7.1.00.0030.01316.82
7.0.200.0030.01016.66
7.0.190.0130.00016.44
7.0.180.0070.01016.19
7.0.170.0100.00316.33
7.0.160.0070.01016.20
7.0.150.0070.01016.36
7.0.140.0000.01716.25
7.0.130.0000.01316.49
7.0.120.0000.01316.61
7.0.110.0070.00716.41
7.0.100.0070.00716.54
7.0.90.0100.00716.20
7.0.80.0070.00716.57
7.0.70.0030.01316.46
7.0.60.0030.01016.15
7.0.50.0030.01316.40
7.0.40.0030.01016.51
7.0.30.0030.01316.38
7.0.20.0070.01016.34
7.0.10.0030.01316.34
7.0.00.0030.01016.42

preferences:
66.78 ms | 403 KiB | 5 Q