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' ) ); var_dump( array_column1( 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)
8.3.60.0100.01016.63
8.3.50.0130.00617.36
8.3.40.0090.00618.97
8.3.30.0030.01318.67
8.3.20.0060.00318.63
8.3.10.0040.00418.85
8.3.00.0030.00619.26
8.2.180.0070.00718.41
8.2.170.0110.00422.96
8.2.160.0100.01021.05
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0000.00722.08
8.2.110.0000.01021.18
8.2.100.0000.01117.72
8.2.90.0050.00519.42
8.2.80.0050.00319.39
8.2.70.0060.00317.75
8.2.60.0080.00017.93
8.2.50.0000.00918.07
8.2.40.0050.00218.34
8.2.30.0000.00718.02
8.2.20.0000.00817.58
8.2.10.0050.00317.86
8.2.00.0060.00317.75
8.1.280.0120.00325.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0020.00528.09
8.1.240.0100.00019.13
8.1.230.0060.00620.97
8.1.220.0000.00817.74
8.1.210.0040.00418.92
8.1.200.0030.00617.35
8.1.190.0050.00317.52
8.1.180.0050.00318.10
8.1.170.0040.00418.73
8.1.160.0000.00718.80
8.1.150.0070.00018.64
8.1.140.0000.00817.43
8.1.130.0000.00717.40
8.1.120.0030.00517.51
8.1.110.0030.00517.37
8.1.100.0000.00717.50
8.1.90.0000.00717.52
8.1.80.0000.00717.51
8.1.70.0030.00317.39
8.1.60.0080.00017.51
8.1.50.0000.00817.40
8.1.40.0000.00817.53
8.1.30.0030.00517.52
8.1.20.0080.00017.63
8.1.10.0000.00817.64
8.1.00.0080.00017.52
8.0.300.0030.00620.01
8.0.290.0040.00416.88
8.0.280.0040.00418.36
8.0.270.0030.00317.15
8.0.260.0040.00416.85
8.0.250.0070.00016.95
8.0.240.0040.00416.91
8.0.230.0080.00017.07
8.0.220.0000.00716.95
8.0.210.0100.00016.93
8.0.200.0000.00616.89
8.0.190.0000.00816.89
8.0.180.0000.00716.99
8.0.170.0050.00516.89
8.0.160.0000.00816.82
8.0.150.0030.00616.81
8.0.140.0000.01016.73
8.0.130.0050.00013.37
8.0.120.0040.00416.89
8.0.110.0070.00016.76
8.0.100.0000.00716.89
8.0.90.0040.00416.81
8.0.80.0060.01016.93
8.0.70.0040.00416.96
8.0.60.0040.00416.88
8.0.50.0040.00416.97
8.0.30.0100.01016.97
8.0.20.0100.01017.26
8.0.10.0000.00816.93
8.0.00.0090.01016.91
7.4.330.0040.00313.11
7.4.320.0000.00616.65
7.4.300.0030.00316.47
7.4.290.0030.00616.65
7.4.280.0000.00816.50
7.4.270.0020.00516.54
7.4.260.0030.00313.43
7.4.250.0000.01016.53
7.4.240.0030.00516.47
7.4.230.0000.00716.53
7.4.220.0170.00316.60
7.4.210.0040.01116.61
7.4.200.0000.00816.47
7.4.190.0040.00416.80
7.4.160.0030.01216.62
7.4.150.0160.00616.59
7.4.140.0080.01116.44
7.4.130.0090.00916.65
7.4.120.0070.01016.53
7.4.110.0110.00616.69
7.4.100.0110.01116.39
7.4.90.0120.00616.45
7.4.80.0100.00619.39
7.4.70.0080.00816.40
7.4.60.0080.00816.34
7.4.50.0070.00716.38
7.4.40.0030.01316.54
7.4.30.0000.01516.40
7.4.00.0080.00815.00
7.3.330.0030.00613.27
7.3.320.0030.00313.39
7.3.310.0030.00316.45
7.3.300.0030.00316.45
7.3.290.0140.00016.38
7.3.280.0060.01016.34
7.3.270.0110.00716.55
7.3.260.0160.00316.34
7.3.250.0090.00916.49
7.3.240.0230.00016.39
7.3.230.0140.00316.66
7.3.210.0090.00916.60
7.3.200.0090.00816.40
7.3.190.0200.00016.44
7.3.180.0000.01616.56
7.3.170.0080.00816.44
7.3.160.0100.00616.40
7.3.120.0070.01014.89
7.3.110.0000.01414.67
7.3.100.0080.00715.06
7.3.90.0090.00414.86
7.3.80.0080.00815.09
7.3.70.0020.00814.90
7.3.60.0080.00414.76
7.3.50.0060.00615.03
7.3.40.0080.00314.95
7.3.30.0050.01014.67
7.3.20.0080.00816.64
7.3.10.0040.01016.66
7.3.00.0050.00916.69
7.2.330.0110.01116.70
7.2.320.0200.00316.76
7.2.310.0050.00416.79
7.2.300.0130.00316.65
7.2.290.0100.00716.83
7.2.250.0100.01015.08
7.2.240.0080.01115.16
7.2.230.0070.00915.15
7.2.220.0050.00715.19
7.2.210.0100.00515.15
7.2.200.0090.00515.13
7.2.190.0030.01415.09
7.2.180.0100.00615.18
7.2.170.0060.00815.15
7.2.130.0030.00716.76
7.2.120.0030.01217.00
7.2.110.0060.00616.77
7.2.100.0070.01016.69
7.2.90.0070.01116.77
7.2.80.0040.01216.72
7.2.70.0100.00316.95
7.2.60.0060.00617.05
7.2.50.0030.00616.74
7.2.40.0120.00016.67
7.2.30.0030.00717.00
7.2.20.0000.01217.03
7.2.10.0000.00916.93
7.2.00.0050.00918.07
7.1.330.0050.00815.81
7.1.320.0050.00915.87
7.1.310.0070.00715.85
7.1.300.0050.00715.84
7.1.290.0020.01215.66
7.1.280.0070.00615.91
7.1.270.0040.00915.89
7.1.260.0080.00615.93
7.1.250.0000.01015.84
7.1.100.0060.00618.09
7.1.70.0000.00717.08
7.1.60.0070.01319.40
7.1.50.0170.01034.67
7.1.00.0100.06022.46
7.0.200.0270.00714.89
7.0.140.0070.07021.95
7.0.120.0030.06322.00
7.0.60.0270.06019.98
7.0.50.0030.04718.01
7.0.40.0100.05017.73
7.0.30.0100.08017.84
7.0.20.0100.08017.84
7.0.10.0130.08017.72
7.0.00.0170.06717.81
5.6.280.0000.07320.79
5.6.210.0000.04720.73
5.6.200.0070.04318.22
5.6.190.0100.05318.27
5.6.180.0030.05018.26
5.6.170.0000.05018.18
5.6.160.0130.07718.18
5.6.150.0070.08018.14
5.6.140.0030.05718.17
5.6.130.0030.09018.15
5.6.120.0070.08018.24
5.6.110.0070.04718.17
5.6.100.0070.06718.13
5.6.90.0100.08018.26
5.6.80.0100.07717.67
5.6.70.0070.06717.56
5.6.60.0000.08717.51
5.6.50.0070.05317.67
5.6.40.0130.06717.48
5.6.30.0070.07717.53
5.6.20.0100.04717.64
5.6.10.0100.08017.59
5.6.00.0100.07317.50
5.5.350.0200.04320.34
5.5.340.0100.07318.08
5.5.330.0070.07018.00
5.5.320.0070.08318.02
5.5.310.0100.07717.98
5.5.300.0030.08317.98
5.5.290.0100.07317.98
5.5.280.0070.08317.96
5.5.270.0130.07718.04
5.5.260.0070.03717.98
5.5.250.0000.07017.79
5.5.240.0100.03317.47
5.5.230.0030.04017.43
5.5.220.0070.07317.37
5.5.210.0070.06317.32
5.5.200.0100.06017.33
5.5.190.0030.05317.36
5.5.180.0030.08317.32
5.5.160.0200.07317.46
5.5.150.0030.04717.30
5.5.140.0070.05317.39
5.5.130.0130.07017.34
5.5.120.0030.05317.30
5.5.110.0070.05017.29
5.5.100.0070.05717.24
5.5.90.0100.07717.23
5.5.80.0070.05317.22
5.5.70.0130.06717.23
5.5.60.0030.05317.20
5.5.50.0170.07017.23
5.5.40.0130.07317.33
5.5.30.0070.07717.32
5.5.20.0100.07717.29
5.5.10.0170.06717.29
5.5.00.0030.07717.19
5.4.450.0030.04319.38
5.4.440.0100.07319.34
5.4.430.0030.04319.45
5.4.420.0070.05019.41
5.4.410.0100.07319.08
5.4.400.0130.06718.98
5.4.390.0100.06019.10
5.4.380.0100.03319.03
5.4.370.0100.07319.13
5.4.360.0130.05719.11
5.4.350.0200.04019.27
5.4.340.0130.07318.89
5.4.320.0130.05718.89
5.4.310.0030.07719.02
5.4.300.0030.06719.09
5.4.290.0130.07319.03
5.4.280.0100.07319.27
5.4.270.0100.07718.89
5.4.260.0100.07319.09
5.4.250.0070.05719.11
5.4.240.0200.06318.89
5.4.230.0100.07319.09
5.4.220.0030.08019.12
5.4.210.0130.06719.16
5.4.200.0070.08019.00
5.4.190.0030.07719.26
5.4.180.0070.05019.13
5.4.170.0030.05319.08
5.4.160.0230.06019.03
5.4.150.0100.07019.02
5.4.140.0070.07716.30
5.4.130.0030.07316.28
5.4.120.0030.03716.34
5.4.110.0070.07716.55
5.4.100.0030.07716.45
5.4.90.0030.07716.43
5.4.80.0100.06716.38
5.4.70.0030.07316.48
5.4.60.0130.07316.36
5.4.50.0270.04016.46
5.4.40.0030.04016.41
5.4.30.0070.05316.36
5.4.20.0000.04716.41
5.4.10.0130.05716.38
5.4.00.0030.06315.73
5.3.290.0030.08314.68
5.3.280.0070.06714.69
5.3.270.0100.07314.69
5.3.260.0100.07714.58
5.3.250.0030.06714.59
5.3.240.0100.07014.59
5.3.230.0100.07714.64
5.3.220.0070.07314.69
5.3.210.0070.07714.55
5.3.200.0070.08314.62
5.3.190.0000.07714.54
5.3.180.0070.06714.62
5.3.170.0030.06314.44
5.3.160.0030.05714.55
5.3.150.0070.04714.63
5.3.140.0000.04014.79
5.3.130.0030.04014.63
5.3.120.0030.08014.54
5.3.110.0030.08314.59
5.3.100.0070.07314.08
5.3.90.0070.07714.08
5.3.80.0100.06314.09
5.3.70.0000.04014.07
5.3.60.0100.06714.04
5.3.50.0070.07314.04
5.3.40.0030.05713.99
5.3.30.0170.06013.78
5.3.20.0170.06013.61
5.3.10.0130.06313.72
5.3.00.0100.07313.71
5.2.170.0070.06011.16
5.2.160.0030.05711.19
5.2.150.0000.07011.22
5.2.140.0030.03711.21
5.2.130.0100.05711.14
5.2.120.0070.06311.17
5.2.110.0030.04011.23
5.2.100.0170.05311.34
5.2.90.0100.05011.22
5.2.80.0070.06311.15
5.2.70.0030.03011.01
5.2.60.0100.06011.08
5.2.50.0070.05010.89
5.2.40.0000.04011.05
5.2.30.0030.03311.20
5.2.20.0000.03011.01
5.2.10.0070.02310.93
5.2.00.0000.03010.72
5.1.60.0100.03310.10
5.1.50.0100.02710.00
5.1.40.0030.02010.04
5.1.30.0030.02310.37
5.1.20.0000.02710.38
5.1.10.0000.02710.09
5.1.00.0000.02710.09
5.0.50.0030.0178.61
5.0.40.0070.0138.41
5.0.30.0000.0308.32
5.0.20.0000.0308.32
5.0.10.0000.0208.04
5.0.00.0000.0308.18
4.4.90.0070.0137.70
4.4.80.0070.0307.70
4.4.70.0000.0207.70
4.4.60.0000.0177.70
4.4.50.0000.0177.70
4.4.40.0000.0277.70
4.4.30.0000.0177.70
4.4.20.0030.0137.70
4.4.10.0030.0207.70
4.4.00.0000.0237.70
4.3.110.0030.0137.70
4.3.100.0030.0137.70
4.3.90.0000.0137.70
4.3.80.0030.0237.70
4.3.70.0000.0137.70
4.3.60.0000.0137.70
4.3.50.0000.0177.70
4.3.40.0000.0237.70
4.3.30.0000.0177.70
4.3.20.0030.0137.70
4.3.10.0000.0177.70
4.3.00.0030.0137.70

preferences:
54.28 ms | 400 KiB | 5 Q