3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('array_column')) { function array_column($input, $column_key, $index_key = null) { if ($index_key !== null) { // Collect the keys $keys = array(); $i = 0; // Counter for numerical keys when key does not exist foreach ($input as $row) { if (array_key_exists($index_key, $row)) { // Update counter for numerical keys if (is_numeric($row[$index_key]) || is_bool($row[$index_key])) { $i = max($i, (int) $row[$index_key] + 1); } // Get the key from a single column of the array $keys[] = $row[$index_key]; } else { // The key does not exist, use numerical indexing $keys[] = $i++; } } } if ($column_key !== null) { // Collect the values $values = array(); $i = 0; // Counter for removing keys foreach ($input as $row) { if (array_key_exists($column_key, $row)) { // Get the values from a single column of the input array $values[] = $row[$column_key]; $i++; } elseif (isset($keys)) { // Values does not exist, also drop the key for it array_splice($keys, $i, 1); } } } else { // Get the full arrays $values = array_values($input); } if ($index_key !== null) { return array_combine($keys, $values); } return $values; } echo "Custom array_column()"; } $records = array( array( 'id' => 2135, 'first_name' => 'John', 'last_name' => 'Doe', ), array( 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith', ), array( 'id' => 5342, 'first_name' => 'Jane', 'last_name' => 'Jones', ), array( 'id' => 5623, 'first_name' => 'Peter', 'last_name' => 'Doe', ) ); $start = microtime(true); for ($i=0;$i<9999;$i++) { array_column($records, 'first_name'); } $end = microtime(true); echo $end-$start."\n";

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)
7.2.00.0000.01219.53
7.1.70.0000.01017.19
7.1.60.0160.01319.17
7.1.50.0070.01816.89
7.1.00.0070.04322.31
7.0.200.0210.00614.85
7.0.140.0070.07321.96
7.0.100.0070.05020.18
7.0.90.0100.08319.98
7.0.80.0270.07019.97
7.0.70.0100.07319.94
7.0.60.0400.05719.86
7.0.50.0070.07020.34
7.0.40.0070.08020.04
7.0.30.0130.08320.14
7.0.20.0070.08720.11
7.0.10.0100.08020.08
7.0.00.0030.05320.03
5.6.280.0100.07021.13
5.6.250.0030.09720.68
5.6.240.0130.04720.71
5.6.230.0230.07720.76
5.6.220.0100.08320.50
5.6.210.0030.06720.59
5.6.200.0130.08021.07
5.6.190.0030.08721.07
5.6.180.0070.08321.03
5.6.170.0100.08021.15
5.6.160.0070.08021.02
5.6.150.0170.07321.05
5.6.140.0100.08321.17
5.6.130.0070.07721.02
5.6.120.0100.05721.09
5.6.110.0130.08321.06
5.6.100.0170.07721.13
5.6.90.0100.05321.07
5.6.80.0070.05320.49
5.6.70.0070.04720.40
5.6.60.0100.06020.42
5.6.50.0130.07720.40
5.6.40.0070.08020.30
5.6.30.0070.08320.43
5.6.20.0100.07720.38
5.6.10.0130.08020.46
5.6.00.0070.08320.52
5.5.380.0030.08320.38
5.5.370.0070.08720.38
5.5.360.0170.05320.45
5.5.350.0100.06720.34
5.5.340.0170.08020.75
5.5.330.0100.05320.75
5.5.320.0000.08320.95
5.5.310.0170.07720.82
5.5.300.0070.07720.89
5.5.290.0070.08720.89
5.5.280.0000.06320.93
5.5.270.0200.06020.93
5.5.260.0070.05320.64
5.5.250.0070.09020.58
5.5.240.0100.09320.33
5.5.230.0170.07320.31
5.5.220.0030.07320.27
5.5.210.0100.07720.28
5.5.200.0200.06720.26
5.5.190.0070.08720.26
5.5.180.0200.08020.24
5.5.160.0100.05020.22
5.5.150.0100.07320.27
5.5.140.0200.07720.23
5.5.130.0100.09020.22
5.5.120.0100.07720.23
5.5.110.0170.07320.20
5.5.100.0000.08020.05
5.5.90.0100.08020.16
5.5.80.0230.06320.16
5.5.70.0100.08020.04
5.5.60.0100.08720.05
5.5.50.0100.08320.16
5.5.40.0200.07720.13
5.5.30.0070.08320.16
5.5.20.0100.07020.06
5.5.10.0100.08019.96
5.5.00.0100.08319.95
5.4.450.0030.06019.47
5.4.440.0130.09019.36
5.4.430.0070.10019.36
5.4.420.0170.09019.55
5.4.410.0100.09319.32
5.4.400.0000.06319.14
5.4.390.0030.09319.13
5.4.380.0130.09319.04
5.4.370.0070.06719.12
5.4.360.0130.08319.13
5.4.350.0070.08719.05
5.4.340.0030.09719.09
5.4.320.0070.11319.20
5.4.310.0030.06019.05
5.4.300.0230.08719.04
5.4.290.0200.08019.14
5.4.280.0070.06019.11
5.4.270.0170.08719.20
5.4.260.0070.09319.23
5.4.250.0100.09719.02
5.4.240.0100.09019.20
5.4.230.0070.06319.23
5.4.220.0130.09318.90
5.4.210.0030.09319.13
5.4.200.0130.05719.16
5.4.190.0070.08719.22
5.4.180.0070.09319.02
5.4.170.0100.09719.11
5.4.160.0070.07719.20
5.4.150.0100.07019.01
5.4.140.0000.06716.48
5.4.130.0170.08316.19
5.4.120.0130.08716.41
5.4.110.0100.08316.45
5.4.100.0070.08016.50
5.4.90.0030.10316.47
5.4.80.0100.06716.37
5.4.70.0000.09716.32
5.4.60.0000.07716.46
5.4.50.0100.08316.33
5.4.40.0000.06716.46
5.4.30.0130.09016.44
5.4.20.0030.09316.41
5.4.10.0200.06716.48
5.4.00.0070.05315.89
5.3.290.0270.08314.74
5.3.280.0100.10314.54
5.3.270.0130.09314.60
5.3.260.0030.06314.71
5.3.250.0130.08714.64
5.3.240.0030.09714.68
5.3.230.0070.06314.59
5.3.220.0030.06714.57
5.3.210.0170.05014.55
5.3.200.0030.06714.52
5.3.190.0070.10314.50
5.3.180.0000.09314.51
5.3.170.0070.07714.55
5.3.160.0070.08314.70
5.3.150.0100.09314.55
5.3.140.0130.08314.60
5.3.130.0030.08314.63
5.3.120.0070.10014.53
5.3.110.0130.10714.48
5.3.100.0000.10314.19
5.3.90.0070.09313.96
5.3.80.0170.07314.06
5.3.70.0070.09313.91
5.3.60.0070.09014.07
5.3.50.0030.08713.95
5.3.40.0070.09314.02
5.3.30.0100.08313.86
5.3.20.0070.08713.80
5.3.10.0000.07713.59
5.3.00.0130.08313.57
5.2.170.0000.08011.08
5.2.160.0000.07311.25
5.2.150.0000.10311.20
5.2.140.0100.10011.22
5.2.130.0070.08711.23
5.2.120.0100.08711.03
5.2.110.0000.06711.19
5.2.100.0030.09311.22
5.2.90.0000.05711.11
5.2.80.0030.09711.11
5.2.70.0000.11011.22
5.2.60.0130.08310.95
5.2.50.0030.10011.07
5.2.40.0070.09711.07
5.2.30.0000.09011.04
5.2.20.0030.09011.00
5.2.10.0100.07010.90
5.2.00.0070.08010.60
5.1.60.0030.06310.07
5.1.50.0070.04710.06
5.1.40.0100.0839.98
5.1.30.0070.08010.49
5.1.20.0030.09310.46
5.1.10.0070.0779.93
5.1.00.0030.0879.95
5.0.50.0000.1108.52
5.0.40.0030.1038.32
5.0.30.0070.1138.22
5.0.20.0000.0908.30
5.0.10.0000.1108.28
5.0.00.0070.1178.23
4.4.90.0000.0908.22
4.4.80.0000.1038.22
4.4.70.0000.0608.22
4.4.60.0030.1008.22
4.4.50.0070.0738.22
4.4.40.0030.1208.22
4.4.30.0030.0808.22
4.4.20.0030.1108.22
4.4.10.0000.1078.22
4.4.00.0030.1078.22
4.3.110.0130.0678.22
4.3.100.0070.0978.22
4.3.90.0000.0908.22
4.3.80.0000.1238.22
4.3.70.0000.0878.22
4.3.60.0100.0638.22
4.3.50.0030.1038.22
4.3.40.0030.0938.22
4.3.30.0070.0808.22
4.3.20.0000.0938.22
4.3.10.0000.1038.22
4.3.00.0000.1038.22

preferences:
34.8 ms | 401 KiB | 5 Q