3v4l.org

run code in 300+ PHP versions simultaneously
<?php // copied from https://github.com/ramsey/array_column/blob/master/src/array_column.php // You can install by composer. // I was just testing from which versions this will work function array_column($input = null, $columnKey = null, $indexKey = null) { // Using func_get_args() in order to check for proper number of // parameters and trigger errors exactly as the built-in array_column() // does in PHP 5.5. $params = func_get_args(); if (!isset($params[0])) { trigger_error('array_column() expects at least 2 parameters, 0 given', E_USER_WARNING); return null; } elseif (!isset($params[1])) { trigger_error('array_column() expects at least 2 parameters, 1 given', E_USER_WARNING); return null; } if (!is_array($params[0])) { trigger_error('array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', E_USER_WARNING); return null; } if (!is_int($params[1]) && !is_string($params[1]) && !(is_object($params[1]) && method_exists($params[1], '__toString')) ) { trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); return false; } if (isset($params[2]) && !is_int($params[2]) && !is_string($params[2]) && !(is_object($params[2]) && method_exists($params[2], '__toString')) ) { trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); return false; } $paramsInput = $params[0]; $paramsColumnKey = (string) $params[1]; $paramsIndexKey = (isset($params[2]) ? (string) $params[2] : null); $resultArray = array(); foreach ($paramsInput as $row) { $key = $value = null; $keySet = $valueSet = false; if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { $keySet = true; $key = $row[$paramsIndexKey]; } if (is_array($row) && array_key_exists($paramsColumnKey, $row)) { $valueSet = true; $value = $row[$paramsColumnKey]; } if ($valueSet) { if ($keySet) { $resultArray[$key] = $value; } else { $resultArray[] = $value; } } } return $resultArray; } $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' ) ); $lastNames = array_column($records, 'last_name', 'id'); var_dump($lastNames);

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)
5.4.450.0070.06319.25
5.4.440.0030.03719.30
5.4.430.0030.03719.51
5.4.420.0030.07719.51
5.4.410.0070.07719.16
5.4.400.0100.03018.95
5.4.390.0030.08719.26
5.4.380.0070.07019.26
5.4.370.0070.07718.93
5.4.360.0130.05718.98
5.4.350.0030.07319.17
5.4.340.0100.07018.90
5.4.320.0030.03719.25
5.4.310.0030.07018.98
5.4.300.0030.04719.25
5.4.290.0030.03719.18
5.4.280.0100.03318.95
5.4.270.0030.05319.13
5.4.260.0070.03718.95
5.4.250.0030.05019.28
5.4.240.0130.05719.28
5.4.230.0030.06719.29
5.4.220.0070.08318.98
5.4.210.0030.06719.25
5.4.200.0070.07719.11
5.4.190.0130.06319.25
5.4.180.0070.06719.13
5.4.170.0030.06319.27
5.4.160.0100.05318.91
5.4.150.0030.07718.94
5.4.140.0070.03016.50
5.4.130.0030.03316.31
5.4.120.0030.05316.51
5.4.110.0000.05316.43
5.4.100.0130.06716.22
5.4.90.0030.07016.38
5.4.80.0130.05716.45
5.4.70.0030.04716.48
5.4.60.0100.03016.20
5.4.50.0030.07316.29
5.4.40.0030.07316.55
5.4.30.0030.07716.42
5.4.20.0030.04316.29
5.4.10.0100.07316.28
5.4.00.0130.06315.90
5.3.290.0030.07014.70
5.3.280.0030.06014.85
5.3.270.0070.06714.63
5.3.260.0030.08014.65
5.3.250.0030.05314.60
5.3.240.0030.03314.71
5.3.230.0070.04314.75
5.3.220.0100.02714.61
5.3.210.0030.06314.58
5.3.200.0030.08014.68
5.3.190.0100.06714.69
5.3.180.0070.05314.61
5.3.170.0000.07714.73
5.3.160.0000.03714.60
5.3.150.0000.08014.63
5.3.140.0030.04714.58
5.3.130.0030.08714.70
5.3.120.0030.03314.59
5.3.110.0070.04714.43
5.3.100.0030.07714.02
5.3.90.0130.07014.00
5.3.80.0100.06314.00
5.3.70.0030.03714.00
5.3.60.0100.05014.03
5.3.50.0100.05314.07
5.3.40.0030.03314.00
5.3.30.0070.05314.06
5.3.20.0070.03013.86
5.3.10.0100.02713.63
5.3.00.0030.07713.68
5.2.170.0000.03711.18
5.2.160.0000.05311.25
5.2.150.0000.04011.26
5.2.140.0000.03011.18
5.2.130.0100.03011.19
5.2.120.0070.04311.36
5.2.110.0030.02711.12
5.2.100.0100.04311.21
5.2.90.0030.05711.19
5.2.80.0100.05711.09
5.2.70.0030.05711.34
5.2.60.0030.03011.30
5.2.50.0030.05311.02
5.2.40.0070.05710.99
5.2.30.0100.04710.98
5.2.20.0030.06310.98
5.2.10.0030.06011.11
5.2.00.0070.05710.76
5.1.60.0070.0509.99
5.1.50.0030.03010.00
5.1.40.0100.04710.00
5.1.30.0130.04710.46
5.1.20.0100.04310.39
5.1.10.0100.04710.07
5.1.00.0070.04310.10
5.0.50.0030.0409.70
5.0.40.0070.0309.70
5.0.30.0000.0339.70
5.0.20.0030.0439.70
5.0.10.0000.0479.70
5.0.00.0000.0679.70
4.4.90.0000.0239.70
4.4.80.0070.0279.70
4.4.70.0000.0209.70
4.4.60.0000.0339.70
4.4.50.0000.0279.70
4.4.40.0000.0439.70
4.4.30.0030.0239.70
4.4.20.0070.0309.70
4.4.10.0000.0209.70
4.4.00.0030.0539.70
4.3.110.0000.0309.70
4.3.100.0030.0309.70
4.3.90.0000.0309.70
4.3.80.0000.0479.70
4.3.70.0030.0339.70
4.3.60.0070.0179.70
4.3.50.0030.0339.70
4.3.40.0000.0509.70
4.3.30.0000.0379.70
4.3.20.0000.0409.70
4.3.10.0000.0339.70
4.3.00.0000.0339.70

preferences:
144 ms | 1394 KiB | 7 Q