3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array( 'post' => array( 'tr' => array( 'slug' => 'a' ), 'en' => array('slug'=>'a') ) ); echo var_dump(array_column($a, 'slug')); /** * This file is part of the array_column library * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @copyright Copyright (c) 2013 Ben Ramsey <http://benramsey.com> * @license http://opensource.org/licenses/MIT MIT */ 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. $argc = func_num_args(); $params = func_get_args(); if ($argc < 2) { trigger_error("array_column() expects at least 2 parameters, {$argc} 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_float($params[1]) && !is_string($params[1]) && $params[1] !== null && !(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_float($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 = ($params[1] !== null) ? (string) $params[1] : null; $paramsIndexKey = null; if (isset($params[2])) { if (is_float($params[2]) || is_int($params[2])) { $paramsIndexKey = (int) $params[2]; } else { $paramsIndexKey = (string) $params[2]; } } $resultArray = array(); foreach ($paramsInput as $row) { $key = $value = null; $keySet = $valueSet = false; if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { $keySet = true; $key = (string) $row[$paramsIndexKey]; } if ($paramsColumnKey === null) { $valueSet = true; $value = $row; } elseif (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; } ?>

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.0700.04719.31
5.4.440.1430.04019.49
5.4.430.1330.05019.20
5.4.420.1330.05319.47
5.4.410.0930.04319.14
5.4.400.0330.03318.98
5.4.390.0300.04319.20
5.4.380.0270.05318.63
5.4.370.0230.05718.58
5.4.360.0370.05718.64
5.4.350.0270.05318.55
5.4.340.0230.06018.75
5.4.320.0050.03612.53
5.4.310.0090.03412.52
5.4.300.0060.03512.52
5.4.290.0050.04012.52
5.4.280.0070.03412.41
5.4.270.0020.03912.42
5.4.260.0020.04112.42
5.4.250.0070.04412.42
5.4.240.0040.03912.42
5.4.230.0040.03812.41
5.4.220.0060.04212.41
5.4.210.0050.04112.41
5.4.200.0040.03712.41
5.4.190.0100.04012.41
5.4.180.0020.03912.40
5.4.170.0040.04412.41
5.4.160.0050.03512.41
5.4.150.0050.03812.41
5.4.140.0050.03612.09
5.4.130.0060.04012.08
5.4.120.0040.03512.03
5.4.110.0070.03312.03
5.4.100.0090.03512.03
5.4.90.0060.04012.04
5.4.80.0070.03912.04
5.4.70.0060.03812.02
5.4.60.0040.03612.03
5.4.50.0070.03312.03
5.4.40.0070.03212.02
5.4.30.0060.03412.01
5.4.20.0060.03512.02
5.4.10.0060.03912.01
5.4.00.0060.03611.50
5.3.290.0050.04912.80
5.3.280.0070.03712.71
5.3.270.0040.04012.72
5.3.260.0040.04112.72
5.3.250.0050.03812.72
5.3.240.0050.03712.72
5.3.230.0060.04012.71
5.3.220.0050.03712.68
5.3.210.0090.03912.68
5.3.200.0050.03912.68
5.3.190.0050.03712.68
5.3.180.0080.03212.67
5.3.170.0110.03912.67
5.3.160.0060.03612.67
5.3.150.0060.03612.67
5.3.140.0050.03612.67
5.3.130.0040.04012.66
5.3.120.0050.03912.66
5.3.110.0060.03812.66
5.3.100.0060.03712.14
5.3.90.0050.03812.13
5.3.80.0040.03712.12
5.3.70.0070.04012.12
5.3.60.0050.04212.11
5.3.50.0060.04112.05
5.3.40.0110.03412.05
5.3.30.0060.03612.01
5.3.20.0080.03611.79
5.3.10.0050.03611.76
5.3.00.0030.03711.74
5.2.170.0060.0319.25
5.2.160.0020.0309.25
5.2.150.0080.0339.25
5.2.140.0020.0329.25
5.2.130.0060.0269.21
5.2.120.0020.0329.21
5.2.110.0060.0369.21
5.2.100.0020.0359.21
5.2.90.0010.0319.21
5.2.80.0010.0339.20
5.2.70.0060.0299.20
5.2.60.0040.0319.16
5.2.50.0040.0319.13
5.2.40.0030.0299.11
5.2.30.0070.0339.08
5.2.20.0060.0299.07
5.2.10.0070.0268.98
5.2.00.0060.0268.84
5.1.60.0050.0258.12
5.1.50.0050.0238.11
5.1.40.0050.0238.10
5.1.30.0090.0258.44
5.1.20.0080.0258.47
5.1.10.0070.0268.20
5.1.00.0020.0278.20
5.0.50.0030.0216.68
5.0.40.0010.0216.54
5.0.30.0030.0316.36
5.0.20.0050.0216.32
5.0.10.0040.0196.30
5.0.00.0030.0306.30
4.4.90.0050.0214.78
4.4.80.0040.0184.76
4.4.70.0040.0174.75
4.4.60.0030.0154.75
4.4.50.0020.0174.77
4.4.40.0030.0254.71
4.4.30.0030.0214.75
4.4.20.0040.0154.85
4.4.10.0020.0174.85
4.4.00.0030.0344.76
4.3.110.0020.0174.67
4.3.100.0050.0144.66
4.3.90.0020.0214.63
4.3.80.0020.0254.59
4.3.70.0020.0194.63
4.3.60.0040.0134.63
4.3.50.0050.0124.63
4.3.40.0020.0254.54
4.3.30.0030.0223.35
4.3.20.0030.0143.33
4.3.10.0030.0143.28
4.3.00.0200.01714.98

preferences:
142.38 ms | 1394 KiB | 7 Q