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 */ if (!function_exists('array_column')) { /** * Returns the values from a single column of the input array, identified by * the $columnKey. * * Optionally, you may provide an $indexKey to index the values in the returned * array by the values from the $indexKey column in the input array. * * @param array $input A multi-dimensional array (record set) from which to pull * a column of values. * @param mixed $columnKey The column of values to return. This value may be the * integer key of the column you wish to retrieve, or it * may be the string key name for an associative array. * @param mixed $indexKey (Optional.) The column to use as the index/keys for * the returned array. This value may be the integer key * of the column, or it may be the string key name. * @return array */ 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)
8.3.60.0150.00318.43
8.3.50.0040.01221.92
8.3.40.0110.00418.84
8.3.30.0070.00718.94
8.3.20.0000.00720.39
8.3.10.0040.00423.71
8.3.00.0080.00017.91
8.2.180.0180.00416.50
8.2.170.0120.00922.96
8.2.160.0140.00020.39
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0060.00321.00
8.2.110.0090.00022.05
8.2.100.0000.01217.70
8.2.90.0050.00319.05
8.2.80.0030.00517.97
8.2.70.0060.00317.49
8.2.60.0090.00017.91
8.2.50.0060.00618.07
8.2.40.0000.00818.22
8.2.30.0030.00718.18
8.2.20.0040.00417.84
8.2.10.0000.00718.03
8.2.00.0000.00717.80
8.1.280.0080.00625.92
8.1.270.0090.00023.77
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0000.00923.66
8.1.230.0080.00419.16
8.1.220.0030.00617.74
8.1.210.0030.00618.77
8.1.200.0030.00717.47
8.1.190.0060.00317.10
8.1.180.0030.00618.10
8.1.170.0000.00818.47
8.1.160.0000.00722.12
8.1.150.0000.00818.92
8.1.140.0050.00317.50
8.1.130.0030.00317.88
8.1.120.0000.00717.51
8.1.110.0080.00017.46
8.1.100.0040.00417.54
8.1.90.0000.00717.48
8.1.80.0040.00417.47
8.1.70.0080.00017.47
8.1.60.0030.00617.63
8.1.50.0050.00317.49
8.1.40.0040.00417.57
8.1.30.0040.00417.69
8.1.20.0000.00817.61
8.1.10.0000.00817.46
8.1.00.0020.00517.57
8.0.300.0000.00819.21
8.0.290.0070.00016.75
8.0.280.0000.00818.53
8.0.270.0000.00817.29
8.0.260.0030.00317.23
8.0.250.0070.00016.98
8.0.240.0080.00016.98
8.0.230.0070.00017.05
8.0.220.0000.00716.85
8.0.210.0040.00417.00
8.0.200.0000.00816.87
8.0.190.0050.00316.90
8.0.180.0040.00416.98
8.0.170.0050.00316.95
8.0.160.0000.00716.84
8.0.150.0040.00316.79
8.0.140.0000.00716.93
8.0.130.0030.00313.41
8.0.120.0060.00316.89
8.0.110.0050.00316.99
8.0.100.0000.00717.00
8.0.90.0050.00316.83
8.0.80.0130.00316.98
8.0.70.0040.00416.89
8.0.60.0020.00516.84
8.0.50.0000.00816.73
8.0.30.0120.00617.02
8.0.20.0080.01417.40
8.0.10.0030.00616.88
8.0.00.0090.01116.73
7.4.330.0000.00515.18
7.4.320.0030.00316.63
7.4.300.0060.00016.55
7.4.290.0030.00316.64
7.4.280.0040.00416.59
7.4.270.0080.00016.57
7.4.260.0040.00416.52
7.4.250.0000.00716.60
7.4.240.0040.00416.54
7.4.230.0040.00416.48
7.4.220.0140.00316.59
7.4.210.0000.01316.59
7.4.200.0050.00216.59
7.4.160.0080.00816.55
7.4.150.0090.00917.40
7.4.140.0100.00717.86
7.4.130.0050.01416.52
7.4.120.0080.00916.52
7.4.110.0100.00716.36
7.4.100.0120.00916.52
7.4.90.0070.01016.51
7.4.80.0100.01319.39
7.4.70.0110.00516.49
7.4.60.0110.00516.54
7.4.50.0040.00416.66
7.4.40.0120.00316.64
7.4.30.0110.00516.37
7.4.00.0070.01015.24
7.3.330.0060.00013.05
7.3.320.0030.00313.18
7.3.310.0030.00416.20
7.3.300.0000.00716.05
7.3.290.0040.01116.25
7.3.280.0040.01216.24
7.3.270.0140.00317.40
7.3.260.0170.00716.25
7.3.250.0100.00816.19
7.3.240.0100.01016.28
7.3.230.0090.00916.47
7.3.210.0070.01016.29
7.3.200.0100.00719.39
7.3.190.0060.01216.25
7.3.180.0070.01016.49
7.3.170.0130.00616.27
7.3.160.0100.00716.23
7.3.120.0050.00814.75
7.2.330.0110.00716.71
7.2.320.0070.01016.56
7.2.310.0040.01316.39
7.2.300.0060.01216.61
7.2.290.0110.00716.46
7.2.110.0160.00816.46
7.2.100.0240.00316.51
7.2.90.0170.01116.48
7.2.80.0000.02816.55
7.2.70.0060.02416.78
7.2.60.0190.01116.91
7.2.50.0220.00716.82
7.2.40.0230.00316.82
7.2.30.0150.01516.49
7.2.20.0300.00016.77
7.2.10.0160.01316.70
7.2.00.0090.00916.68
7.1.230.0130.00915.69
7.1.220.0230.00015.51
7.1.210.0180.00815.74
7.1.200.0180.01215.48
7.1.190.0210.00615.75
7.1.180.0120.01515.73
7.1.170.0110.01115.76
7.1.160.0080.01915.80
7.1.150.0100.01215.53
7.1.140.0130.01215.41
7.1.130.0130.01315.68
7.1.120.0250.00015.42
7.1.110.0160.00915.59
7.1.100.0180.00915.65
7.1.90.0190.00615.94
7.1.80.0210.00415.58
7.1.70.0070.01216.45
7.1.60.0160.01217.75
7.1.50.0150.01116.31
7.1.40.0070.01316.06
7.1.30.0200.01215.52
7.1.20.0110.01815.69
7.1.10.0370.01415.38
7.1.00.0220.04118.88
7.0.310.0230.00314.95
7.0.300.0060.01714.95
7.0.290.0160.00815.21
7.0.280.0120.00815.04
7.0.270.0170.00415.18
7.0.260.0170.00615.13
7.0.250.0240.00015.14
7.0.240.0190.00615.16
7.0.230.0130.01315.41
7.0.220.0070.01815.30
7.0.210.0150.01015.27
7.0.200.0060.01115.91
7.0.190.0140.01015.51
7.0.180.0180.00715.50
7.0.170.0140.01015.22
7.0.160.0150.00815.44
7.0.150.0250.01114.98
7.0.140.0300.03918.64
7.0.130.0300.00915.25
7.0.120.0430.00715.34
7.0.110.0300.03317.54
7.0.100.0290.04117.63
7.0.90.0140.03817.64
7.0.80.0180.05117.54
7.0.70.0180.04617.70
7.0.60.0330.04117.55
7.0.50.0140.04817.83
7.0.40.0170.03916.76
7.0.30.0120.05216.71
7.0.20.0140.04116.74
7.0.10.0130.04116.81
7.0.00.0220.03416.71
5.6.380.0180.00913.87
5.6.370.0140.01014.12
5.6.360.0170.00814.53
5.6.350.0110.01113.93
5.6.340.0190.00714.20
5.6.330.0150.00914.01
5.6.320.0160.01014.12
5.6.310.0100.01313.90
5.6.300.0410.00614.23
5.6.290.0270.00914.46
5.6.280.0220.03717.67
5.6.270.0190.01014.11
5.6.260.0160.04317.35
5.6.250.0180.04717.23
5.6.240.0230.02417.31
5.6.230.0180.04717.43
5.6.220.0210.02517.47
5.6.210.0210.03817.38
5.6.200.0150.04717.52
5.6.190.0150.03417.65
5.6.180.0150.03417.71
5.6.170.0080.04617.75
5.6.160.0080.03117.88
5.6.150.0140.04117.61
5.6.140.0100.04317.83
5.6.130.0120.04717.57
5.6.120.0140.04417.74
5.6.110.0070.03617.70
5.6.100.0150.02717.64
5.6.90.0090.03317.88
5.6.80.0070.02617.38
5.6.70.0060.02817.40
5.6.60.0080.02817.21
5.6.50.0080.02717.34
5.6.40.0100.02517.35
5.6.30.0100.02817.34
5.6.20.0110.02217.37
5.6.10.0140.02017.31
5.6.00.0090.02417.28
5.5.380.0170.04015.74
5.5.370.0050.03615.76
5.5.360.0100.04215.63
5.5.350.0120.03715.77
5.5.340.0100.04315.89
5.5.330.0120.04316.03
5.5.320.0070.04515.86
5.5.310.0130.03815.97
5.5.300.0090.04615.95
5.5.290.0080.04315.98
5.5.280.0190.03716.21
5.5.270.0060.04715.94
5.5.260.0100.02615.99
5.5.250.0080.02115.87
5.5.240.0110.02115.61
5.5.230.0040.02515.70
5.5.220.0060.02215.53
5.5.210.0070.02615.79
5.5.200.0080.02215.77
5.5.190.0050.02515.71
5.5.180.0120.03515.58
5.5.170.0200.00614.01
5.5.160.0070.02315.75
5.5.150.0070.02415.44
5.5.140.0090.01815.71
5.5.130.0020.03515.46
5.5.120.0030.02715.71
5.5.110.0060.02715.52
5.5.100.0100.02015.80
5.5.90.0090.01915.52
5.5.80.0100.02015.49
5.5.70.0060.02415.67
5.5.60.0090.02015.62
5.5.50.0060.02115.65
5.5.40.0050.02315.52
5.5.30.0050.02615.79
5.5.20.0100.03615.71
5.5.10.0090.02015.56
5.5.00.0040.02815.48
5.4.450.0070.03715.13
5.4.440.0100.03915.18
5.4.430.0100.02915.32
5.4.420.0120.02015.35
5.4.410.0100.02915.09
5.4.400.0140.01715.15
5.4.390.0110.02015.10
5.4.380.0040.02215.05
5.4.370.0070.02015.07
5.4.360.0030.02614.84
5.4.350.0080.03514.92
5.4.340.0070.02515.08
5.4.330.0090.00310.78
5.4.320.0060.02514.95
5.4.310.0090.01915.02
5.4.300.0070.02215.10
5.4.290.0130.02314.96
5.4.280.0060.02314.86
5.4.270.0090.03715.19
5.4.260.0040.02315.13
5.4.250.0040.03815.13
5.4.240.0080.02014.82
5.4.230.0060.02114.97
5.4.220.0040.02914.95
5.4.210.0090.02015.09
5.4.200.0040.02415.03
5.4.190.0070.02314.79
5.4.180.0060.02814.88
5.4.170.0040.02514.89
5.4.160.0090.02014.88
5.4.150.0030.02515.13
5.4.140.0070.02013.74
5.4.130.0080.03013.52
5.4.120.0030.02813.65
5.4.110.0070.03313.72
5.4.100.0050.02213.70
5.4.90.0070.03613.90
5.4.80.0090.01813.64
5.4.70.0110.03213.77
5.4.60.0100.03813.57
5.4.50.0100.03913.59
5.4.40.0060.02613.71
5.4.30.0110.03513.57
5.4.20.0120.03313.59
5.4.10.0090.04013.70
5.4.00.0140.03513.33
5.3.290.0090.03012.62
5.3.280.0030.02312.50
5.3.270.0080.02212.46
5.3.260.0060.01812.63
5.3.250.0070.02212.52
5.3.240.0100.01912.52
5.3.230.0080.02212.50
5.3.220.0080.02112.51
5.3.210.0070.02712.46
5.3.200.0080.01912.53
5.3.190.0060.02612.51
5.3.180.0130.03512.61
5.3.170.0080.03812.61
5.3.160.0060.03912.66
5.3.150.0060.04412.53
5.3.140.0020.04512.63
5.3.130.0140.03312.72
5.3.120.0090.04012.57
5.3.110.0060.04012.67
5.3.100.0070.02412.33
5.3.90.0130.03012.34
5.3.80.0100.03812.17
5.3.70.0070.03912.18
5.3.60.0110.03512.25
5.3.50.0070.03912.24
5.3.40.0110.02012.08
5.3.30.0060.04112.27
5.3.20.0090.02912.08
5.3.10.0090.03411.97
5.3.00.0090.02911.88
5.2.170.0070.03310.85
5.2.160.0070.03011.07
5.2.150.0060.03610.94
5.2.140.0020.03610.86
5.2.130.0050.03311.02
5.2.120.0070.01810.91
5.2.110.0100.03110.97
5.2.100.0090.02311.04
5.2.90.0050.03610.96
5.2.80.0120.02810.94
5.2.70.0020.03710.82
5.2.60.0070.03210.77
5.2.50.0060.03110.88
5.2.40.0050.03510.98
5.2.30.0100.02510.98
5.2.20.0080.02810.89
5.2.10.0080.02510.87
5.2.00.0050.03510.66
5.1.60.0070.02710.50
5.1.50.0040.02510.52
5.1.40.0070.02810.56
5.1.30.0060.03010.53
5.1.20.0070.02010.56
5.1.10.0080.02810.43
5.1.00.0060.02610.40
5.0.50.0030.01810.10
5.0.40.0000.01410.09
5.0.30.0080.03310.09
5.0.20.0040.02410.09
5.0.10.0030.02510.09
5.0.00.0030.03310.09
4.4.90.0050.01610.09
4.4.80.0000.02210.09
4.4.70.0050.01610.09
4.4.60.0020.01210.09
4.4.50.0050.01810.09
4.4.40.0020.03110.09
4.4.30.0020.01210.09
4.4.20.0040.01910.09
4.4.10.0030.01810.09
4.4.00.0040.01510.09
4.3.110.0010.01910.09
4.3.100.0030.01810.09
4.3.90.0030.01310.09
4.3.80.0080.02310.09
4.3.70.0020.02010.09
4.3.60.0040.01510.09
4.3.50.0040.02010.09
4.3.40.0030.02610.09
4.3.30.0050.01710.09
4.3.20.0040.01710.09
4.3.10.0030.01510.09
4.3.00.0030.01110.09

preferences:
41.57 ms | 400 KiB | 5 Q