3v4l.org

run code in 300+ PHP versions simultaneously
<?php // generic function to generate cross product of multi-dimensional array function arrayCrossProduct( array $data ) { $rowCount = 1; foreach( $data as &$datum ) { $datum = (array) $datum; $rowCount *= count( $datum ); reset( $datum ); // reset the array, just to be sure } unset( $datum ); // drop the reference, just to be safe $result = array(); while( $rowCount-- > 0 ) { $row = array(); foreach( $data as &$datum ) { $row[] = current( $datum ); } $result[] = $row; foreach( $data as &$datum ) { next( $datum ); if( !is_null( key( $datum ) ) ) { break; } reset( $datum ); } } return $result; } // example data $data = array( 'name' => 'Mike', 'country' => 'UK', 'prefers' => array( 'coffee', 'milk', 'bananas' ), 'age' => 25, 'parents' => array( 'John', 'Janine' ), 'children' => array( 'Jack', 'Jill', 'Joline' ) ); $i = 1; foreach( arrayCrossProduct( $data ) as $row ) { echo str_pad( (string) $i++, 2, " ", STR_PAD_LEFT ) . '. ' . implode( ', ', $row ) . PHP_EOL; }

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.70.0130.00316.50
8.3.60.0070.00718.43
8.3.50.0070.01117.25
8.3.40.0120.00318.68
8.3.30.0110.00718.54
8.3.20.0060.01219.34
8.3.10.0120.00321.72
8.3.00.0110.00719.68
8.2.180.0090.00916.32
8.2.170.0100.00722.96
8.2.160.0110.00419.04
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0040.00421.02
8.2.110.0140.00319.32
8.2.100.0060.00617.84
8.2.90.0040.00417.91
8.2.80.0000.00819.27
8.2.70.0100.00017.63
8.2.60.0040.00418.22
8.2.50.0040.00418.10
8.2.40.0040.00418.05
8.2.30.0000.00819.40
8.2.20.0050.00218.03
8.2.10.0040.00418.08
8.2.00.0040.00418.35
8.1.280.0040.01125.92
8.1.270.0160.00322.19
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0060.00319.21
8.1.230.0060.00620.97
8.1.220.0050.00317.78
8.1.210.0000.00818.77
8.1.200.0030.00617.35
8.1.190.0060.00317.36
8.1.180.0000.00818.10
8.1.170.0040.00417.62
8.1.160.0040.00418.88
8.1.150.0070.00020.17
8.1.140.0030.00519.55
8.1.130.0030.00318.86
8.1.120.0040.00417.52
8.1.110.0070.00017.45
8.1.100.0060.00317.37
8.1.90.0050.00317.46
8.1.80.0040.00417.41
8.1.70.0030.00317.50
8.1.60.0030.00717.66
8.1.50.0080.00017.53
8.1.40.0050.00317.45
8.1.30.0080.00017.76
8.1.20.0050.00217.64
8.1.10.0000.00717.54
8.1.00.0040.00417.49
8.0.300.0040.00419.98
8.0.290.0040.00416.75
8.0.280.0000.00718.36
8.0.270.0000.00716.91
8.0.260.0000.00719.08
8.0.250.0000.00817.00
8.0.240.0000.00816.86
8.0.230.0070.00016.95
8.0.220.0000.00716.95
8.0.210.0070.00016.84
8.0.200.0020.00517.02
8.0.190.0040.00416.95
8.0.180.0040.00416.93
8.0.170.0000.00816.85
8.0.160.0030.00316.88
8.0.150.0040.00416.84
8.0.140.0000.00716.79
8.0.130.0000.00613.29
8.0.120.0000.00716.86
8.0.110.0070.00016.92
8.0.100.0040.00416.91
8.0.90.0030.00516.89
8.0.80.0130.00316.88
8.0.70.0000.00816.79
8.0.60.0030.00516.70
8.0.50.0000.00716.94
8.0.30.0130.00817.08
8.0.20.0140.00617.30
8.0.10.0230.00417.05
8.0.00.0120.00816.79
7.4.330.0080.00015.55
7.4.320.0000.00716.53
7.4.300.0000.00616.56
7.4.290.0030.00316.64
7.4.280.0040.00416.66
7.4.270.0040.00416.44
7.4.260.0040.00416.66
7.4.250.0070.00016.50
7.4.240.0040.00416.64
7.4.230.0070.00016.28
7.4.220.0070.01016.59
7.4.210.0100.01016.66
7.4.200.0030.00316.45
7.4.160.0040.01616.66
7.4.150.0110.01116.99
7.4.140.0100.01217.52
7.4.130.0170.00816.53
7.4.120.0170.00616.55
7.4.110.0140.00916.63
7.4.100.0140.00716.58
7.4.90.0110.01116.42
7.4.80.0110.01317.91
7.4.70.0110.01016.49
7.4.60.0120.01116.55
7.4.50.0110.00716.62
7.4.40.0160.00716.48
7.4.30.0150.00816.51
7.4.20.0180.01516.62
7.4.10.0160.01316.53
7.4.00.0130.00915.46
7.3.330.0020.00213.16
7.3.320.0060.00013.15
7.3.310.0070.00016.23
7.3.300.0070.00016.32
7.3.290.0030.00316.38
7.3.280.0060.01116.35
7.3.270.0080.01416.83
7.3.260.0120.00816.51
7.3.250.0140.00916.46
7.3.240.0120.00816.44
7.3.230.0120.01016.51
7.3.220.0220.00416.35
7.3.210.0140.00916.54
7.3.200.0160.00916.42
7.3.190.0150.00816.37
7.3.180.0120.00916.44
7.3.170.0090.01216.36
7.3.160.0100.01216.48
7.3.150.0310.01416.39
7.3.140.0240.00916.30
7.3.130.0110.02116.31
7.3.120.0160.00815.51
7.3.110.0120.00915.55
7.3.100.0110.01515.46
7.3.90.0110.00815.63
7.3.80.0110.01015.63
7.3.70.0100.01315.57
7.3.60.0130.01015.55
7.3.50.0090.01315.62
7.3.40.0120.01015.64
7.3.30.0140.00915.54
7.3.20.0110.01016.52
7.3.10.0100.01016.49
7.3.00.0130.00716.54
7.2.340.0270.00416.44
7.2.330.0130.01016.64
7.2.320.0150.00916.60
7.2.310.0130.01116.63
7.2.300.0120.01316.61
7.2.290.0140.01116.57
7.2.280.0790.00716.37
7.2.270.0350.01216.38
7.2.260.0170.01316.41
7.2.250.0150.00815.59
7.2.240.0120.01215.81
7.2.230.0130.01015.65
7.2.220.0120.00915.57
7.2.210.0150.00815.66
7.2.200.0100.01415.74
7.2.190.0130.00615.87
7.2.180.0090.01415.79
7.2.170.0230.00215.84
7.2.160.0220.00415.75
7.2.150.0130.00916.87
7.2.140.0150.00816.80
7.2.130.0200.00716.78
7.2.120.0140.01216.81
7.2.110.0200.00715.99
7.2.100.0230.00816.12
7.2.90.0190.00715.69
7.2.80.0480.00915.75
7.2.70.0150.00815.87
7.2.60.0540.00716.09
7.2.50.0590.00715.84
7.2.40.0130.01215.87
7.2.30.0300.00415.87
7.2.20.0230.00915.76
7.2.10.0200.00315.83
7.2.00.0200.00915.95
7.1.330.1060.00715.70
7.1.320.0130.00715.62
7.1.310.0110.01015.64
7.1.300.0130.00715.70
7.1.290.0070.01315.71
7.1.280.0120.01015.67
7.1.270.0250.00715.62
7.1.260.0100.00715.62
7.1.250.0130.00715.69
7.1.240.0110.00815.69
7.1.230.0140.01015.15
7.1.220.0130.01315.12
7.1.210.0600.00714.74
7.1.200.0150.00914.89
7.1.190.0190.00614.79
7.1.180.0640.00914.59
7.1.170.0300.00614.65
7.1.160.0740.00714.72
7.1.150.0660.01014.80
7.1.140.0160.00414.78
7.1.130.0170.00814.72
7.1.120.0420.01014.64
7.1.110.0170.00814.68
7.1.100.0160.01014.67
7.1.90.0530.00814.76
7.1.80.0570.00914.84
7.1.70.0380.01115.24
7.1.60.0330.01122.33
7.1.50.0420.00925.95
7.1.40.0440.00925.82
7.1.30.0490.01325.81
7.1.20.0470.01025.77
7.1.10.0520.00915.08
7.1.00.0260.00815.11
7.0.330.0130.00715.34
7.0.320.0300.00515.22
7.0.310.0280.00614.37
7.0.300.0160.01114.45
7.0.290.0690.01014.49
7.0.280.0100.01114.31
7.0.270.0600.00814.40
7.0.260.0300.00614.34
7.0.250.0190.00514.33
7.0.240.0390.00514.48
7.0.230.0530.00614.46
7.0.220.0550.01014.40
7.0.210.0460.00714.43
7.0.200.0380.00714.92
7.0.190.0290.00814.89
7.0.180.0350.00714.78
7.0.170.0400.00914.77
7.0.160.0320.01014.69
7.0.150.0320.00814.83
7.0.140.0110.01014.81
7.0.130.0170.01014.81
7.0.120.0170.00714.79
7.0.110.0230.00714.79
7.0.100.0240.01014.86
7.0.90.0150.00714.78
7.0.80.0150.01014.75
7.0.70.0330.00514.81
7.0.60.0150.00815.02
7.0.50.0260.00715.00
7.0.40.0290.00914.66
7.0.30.0130.00714.62
7.0.20.0320.00814.68
7.0.10.0160.00714.58
7.0.00.0150.00914.57
5.6.400.0130.01015.05
5.6.390.0120.00815.11
5.6.380.0060.01414.83
5.6.370.0110.01115.04
5.6.360.0170.00715.12
5.6.350.0130.01015.01
5.6.340.0090.01214.65
5.6.330.0110.00914.96
5.6.320.0110.01214.93
5.6.310.0220.00414.86
5.6.300.0140.01616.02
5.6.290.0140.02216.29
5.6.280.0180.02416.27
5.6.270.0140.02416.37
5.6.260.0190.02116.40
5.6.250.0110.02616.29
5.6.240.0120.02616.42
5.6.230.0130.02416.44
5.6.220.0120.02316.35
5.6.210.0160.01816.30
5.6.200.0100.02516.25
5.6.190.0140.02016.36
5.6.180.0140.02016.32
5.6.170.0130.02316.31
5.6.160.0120.02216.49
5.6.150.0100.02316.53
5.6.140.0120.02416.33
5.6.130.0110.02116.37
5.6.120.0130.01916.46
5.6.110.0100.02416.45
5.6.100.0120.02216.42
5.6.90.0140.01916.48
5.6.80.0140.01716.13
5.6.70.0130.02216.15
5.6.60.0160.02116.23
5.6.50.0120.02016.22
5.6.40.0090.02216.20
5.6.30.0130.01816.17
5.6.20.0080.02316.17
5.6.10.0060.03316.14
5.6.00.0090.02516.30
5.5.380.0170.00813.63
5.5.370.0110.01113.76
5.5.360.0180.00713.42
5.5.350.0150.00713.43
5.5.340.0160.00713.59
5.5.330.0120.01213.63
5.5.320.0160.01013.59
5.5.310.0170.00813.77
5.5.300.0110.01313.60
5.5.290.0190.00713.61
5.5.280.0170.00713.58
5.5.270.0150.00613.58
5.5.260.0070.01413.76
5.5.250.0240.00713.78
5.5.240.0130.01113.56
5.5.230.0130.00913.55
5.5.220.0150.00813.65
5.5.210.0130.00813.74
5.5.200.0140.00813.50
5.5.190.0100.01013.34
5.5.180.0160.00913.63
5.5.170.0130.01015.24
5.5.160.0110.01313.48
5.5.150.0150.00713.41
5.5.140.0140.00813.53
5.5.130.0140.00713.57
5.5.120.0080.01413.50
5.5.110.0140.01013.61
5.5.100.0180.00513.70
5.5.90.0110.01013.72
5.5.80.0140.00913.62
5.5.70.0120.01013.73
5.5.60.0170.00313.63
5.5.50.0220.01113.66
5.5.40.0160.00813.47
5.5.30.0150.00613.63
5.5.20.0140.00813.57
5.5.10.0160.00813.56
5.5.00.0170.00813.39
5.4.450.0140.00512.07
5.4.440.0160.00512.25
5.4.430.0120.00712.17
5.4.420.0130.00712.24
5.4.410.0130.00712.01
5.4.400.0060.01312.09
5.4.390.0130.00512.23
5.4.380.0140.00512.02
5.4.370.0140.00312.14
5.4.360.0150.00412.04
5.4.350.0100.00712.15
5.4.340.0060.01312.06
5.4.330.0110.00712.24
5.4.320.0100.00912.06
5.4.310.0110.00612.24
5.4.300.0110.00712.14
5.4.290.0090.01212.05
5.4.280.0100.01112.18
5.4.270.0090.01012.09
5.4.260.0110.00711.94
5.4.250.0060.01312.07
5.4.240.0130.00612.12
5.4.230.0140.00711.91
5.4.220.0150.00512.10
5.4.210.0150.00512.17
5.4.200.0140.00412.21
5.4.190.0140.00711.98
5.4.180.0100.01112.07
5.4.170.0140.00512.11
5.4.160.0060.01312.01
5.4.150.0110.00712.12
5.4.140.0140.00812.08
5.4.130.0140.00512.15
5.4.120.0140.00612.09
5.4.110.0120.00612.12
5.4.100.0150.00512.14
5.4.90.0070.01312.14
5.4.80.0150.00312.13
5.4.70.0090.01012.09
5.4.60.0130.00512.22
5.4.50.0100.00912.02
5.4.40.0140.00512.05
5.4.30.0140.00312.12
5.4.20.0110.01112.16
5.4.10.0120.00712.20
5.4.00.0070.01112.10
5.3.290.0100.01112.04
5.3.280.0110.00711.75
5.3.270.0120.00812.01
5.3.260.0100.00811.90
5.3.250.0160.00611.92
5.3.240.0090.00911.80
5.3.230.0080.01011.84
5.3.220.0120.01711.83
5.3.210.0130.00711.79
5.3.200.0060.01311.80
5.3.190.0090.01011.88
5.3.180.0160.00211.91
5.3.170.0100.00911.92
5.3.160.0140.00511.97
5.3.150.0150.00511.91
5.3.140.0120.00711.93
5.3.130.0140.00711.86
5.3.120.0140.00711.92
5.3.110.0120.00811.91
5.3.100.0110.00912.00
5.3.90.0090.00811.98
5.3.80.0090.00811.71
5.3.70.0110.01011.82
5.3.60.0110.00811.85
5.3.50.0120.00511.85
5.3.40.0130.00511.87
5.3.30.0170.00711.80
5.3.20.0100.00611.87
5.3.10.0110.00611.73
5.3.00.0090.01011.72
5.2.170.0090.00811.39
5.2.160.0120.00511.36
5.2.150.0090.00711.36
5.2.140.0120.00311.34
5.2.130.0110.00411.27
5.2.120.0110.00511.30
5.2.110.0070.01011.36
5.2.100.0100.00811.36
5.2.90.0070.00711.32
5.2.80.0080.00711.30
5.2.70.0110.00411.25
5.2.60.0050.01011.24
5.2.50.0090.00611.25
5.2.40.0170.00511.29
5.2.30.0070.01211.26
5.2.20.0060.01011.26
5.2.10.0090.00611.07
5.2.00.0130.00211.15
5.1.60.0080.00810.77
5.1.50.0130.00010.85
5.1.40.0070.00710.89
5.1.30.0090.00510.92
5.1.20.0020.01110.91
5.1.10.0060.00910.85
5.1.00.0070.00710.76
5.0.50.0030.01010.61
5.0.40.0090.00310.61
5.0.30.0060.00710.61
5.0.20.0060.00510.61
5.0.10.0090.00110.61
5.0.00.0140.00410.61
4.4.90.0080.00010.61
4.4.80.0050.00310.61
4.4.70.0050.00410.61
4.4.60.0070.00210.61
4.4.50.0050.00210.61
4.4.40.0060.00210.61
4.4.30.0060.00210.61
4.4.20.0030.00610.61
4.4.10.0030.00610.61
4.4.00.0040.00510.61
4.3.110.0060.00110.61
4.3.100.0040.00310.61
4.3.90.0070.00310.61
4.3.80.0090.00010.61
4.3.70.0090.00010.61
4.3.60.0000.00910.61
4.3.50.0020.00710.61
4.3.40.0040.00410.61
4.3.30.0050.00310.61
4.3.20.0100.00310.61
4.3.10.0020.00610.61
4.3.00.0050.00210.61

preferences:
36.11 ms | 401 KiB | 5 Q