3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_column1($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(); switch (func_num_args()) { case 0: trigger_error('array_column() expects at least 2 parameters, 0 given', E_USER_WARNING); return null; case 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; } } var_dump( array_column( array( array( 'a' => null, 'b' => 16, ), ), 'b', 'a' ) );

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.160.0170.06012.40
5.4.150.0180.04212.40
5.4.140.0170.05112.09
5.4.130.0180.04212.07
5.4.120.0190.04812.04
5.4.110.0270.07012.03
5.4.100.0170.04312.03
5.4.90.0150.04212.03
5.4.80.0160.04212.03
5.4.70.0160.04112.03
5.4.60.0210.04712.03
5.4.50.0150.04312.02
5.4.40.0150.04512.01
5.4.30.0140.04612.01
5.4.20.0140.04312.00
5.4.10.0170.04112.01
5.4.00.0150.04311.50
5.3.260.0130.05012.72
5.3.250.0020.04412.72
5.3.240.0140.04612.72
5.3.230.0200.04812.71
5.3.220.0230.05612.68
5.3.210.0140.04612.68
5.3.200.0170.04512.68
5.3.190.0180.04312.68
5.3.180.0160.04312.67
5.3.170.0150.04412.67
5.3.160.0180.05112.67
5.3.150.0190.05112.67
5.3.140.0190.04012.66
5.3.130.0190.04212.66
5.3.120.0150.04812.66
5.3.110.0180.04312.66
5.3.100.0160.04412.14
5.3.90.0150.04512.12
5.3.80.0160.05412.10
5.3.70.0160.04312.10
5.3.60.0140.04512.09
5.3.50.0230.05912.04
5.3.40.0230.05812.04
5.3.30.0130.04412.00
5.3.20.0140.04311.78
5.3.10.0180.03811.75
5.3.00.0200.04711.73

preferences:
140.57 ms | 1386 KiB | 7 Q