3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_column1($input = null, $columnKey = null, $indexKey = null) { 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($input)) { trigger_error('array_column() expects parameter 1 to be array, ' . gettype($input) . ' given', E_USER_WARNING); return null; } if (null !== $columnKey && !is_int($columnKey) && !is_string($columnKey) && !(is_object($columnKey) && method_exists($columnKey, '__toString')) ) { trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); return false; } if (isset($indexKey) && !is_int($indexKey) && !is_string($indexKey) && !(is_object($indexKey) && method_exists($indexKey, '__toString')) ) { trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); return false; } $resultArray = array(); foreach ($input as $row) { $key = $value = null; $keySet = $valueSet = false; if ($indexKey !== null && array_key_exists($indexKey, $row)) { $keySet = true; $key = $row[$indexKey]; } if (is_array($row)) { if (null === $columnKey) { $valueSet = true; $value = $row; } elseif (array_key_exists($columnKey, $row)) { $valueSet = true; $value = $row[$columnKey]; } } if ($valueSet) { if ($keySet) { $resultArray[$key] = $value; } else { $resultArray[] = $value; } } } return $resultArray; } var_dump( array_column1( array( array( 'a' => null, 'b' => 16, ), ), '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.0180.00018.44
8.3.50.0140.00522.12
8.3.40.0120.00318.81
8.3.30.0110.00319.02
8.3.20.0040.00420.34
8.3.10.0040.00422.09
8.3.00.0000.00822.40
8.2.180.0090.00616.32
8.2.170.0100.00622.96
8.2.160.0040.01120.94
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0060.00317.63
8.2.110.0090.00022.11
8.2.100.0000.01217.91
8.2.90.0060.00319.19
8.2.80.0030.00617.97
8.2.70.0060.00317.75
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0000.00918.16
8.2.30.0040.00418.17
8.2.20.0000.00817.77
8.2.10.0000.00819.64
8.2.00.0030.00517.80
8.1.280.0140.00025.92
8.1.270.0050.00322.21
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0030.00623.89
8.1.230.0080.00418.99
8.1.220.0030.00517.74
8.1.210.0000.00818.77
8.1.200.0000.00917.23
8.1.190.0000.00817.40
8.1.180.0050.00318.10
8.1.170.0080.00018.57
8.1.160.0090.00022.01
8.1.150.0070.00318.66
8.1.140.0040.00417.54
8.1.130.0000.00717.87
8.1.120.0030.00517.48
8.1.110.0040.00417.39
8.1.100.0000.00717.45
8.1.90.0040.00417.44
8.1.80.0070.00017.32
8.1.70.0080.00017.48
8.1.60.0030.00617.58
8.1.50.0040.00417.55
8.1.40.0040.00417.45
8.1.30.0040.00417.64
8.1.20.0000.00817.61
8.1.10.0080.00017.68
8.1.00.0040.00417.49
8.0.300.0050.00218.77
8.0.290.0000.00917.18
8.0.280.0070.00018.36
8.0.270.0070.00017.17
8.0.260.0030.00316.87
8.0.250.0030.00317.04
8.0.240.0030.00516.96
8.0.230.0000.00717.00
8.0.220.0050.00316.97
8.0.210.0030.00316.77
8.0.200.0000.00616.97
8.0.190.0000.00717.04
8.0.180.0000.00716.97
8.0.170.0000.00816.84
8.0.160.0040.00416.99
8.0.150.0000.00716.92
8.0.140.0040.00416.86
8.0.130.0030.00313.40
8.0.120.0060.00316.78
8.0.110.0050.00316.86
8.0.100.0040.00417.05
8.0.90.0000.00816.88
8.0.80.0030.01316.92
8.0.70.0050.00316.76
8.0.60.0040.00416.89
8.0.50.0000.00716.76
8.0.30.0110.01117.11
8.0.20.0110.01117.40
8.0.10.0070.00016.95
8.0.00.0080.01016.79
7.4.330.0050.00015.15
7.4.320.0040.00416.55
7.4.300.0060.00016.57
7.4.290.0080.00016.53
7.4.280.0030.00316.68
7.4.270.0030.00616.63
7.4.260.0000.00816.51
7.4.250.0040.00416.66
7.4.240.0020.00616.52
7.4.230.0070.00016.70
7.4.220.0030.01716.51
7.4.210.0090.00916.53
7.4.200.0000.00716.42
7.4.190.0050.00316.72
7.4.160.0030.01316.52
7.4.150.0130.00417.40
7.4.140.0090.00817.86
7.4.130.0050.01316.50
7.4.120.0080.00916.54
7.4.110.0080.00816.66
7.4.100.0070.01316.65
7.4.90.0030.01316.54
7.4.80.0100.00719.39
7.4.70.0110.00516.41
7.4.60.0130.00316.51
7.4.50.0080.00116.67
7.4.40.0090.00622.77
7.4.30.0110.00516.51
7.4.10.0080.00915.08
7.4.00.0060.01114.97
7.3.330.0020.00213.27
7.3.320.0050.00013.41
7.3.310.0040.00416.44
7.3.300.0050.00216.45
7.3.290.0160.00316.36
7.3.280.0080.00916.41
7.3.270.0100.00717.40
7.3.260.0080.00816.74
7.3.250.0150.00816.56
7.3.240.0130.01016.50
7.3.230.0070.01116.45
7.3.210.0070.01116.69
7.3.200.0110.01119.39
7.3.190.0170.00416.71
7.3.180.0090.00616.46
7.3.170.0090.00616.52
7.3.160.0110.01116.65
7.3.130.0080.00914.83
7.3.120.0090.00914.87
7.3.110.0080.01014.87
7.3.100.0000.01214.72
7.3.90.0050.01014.80
7.3.80.0060.00614.75
7.3.70.0050.00714.75
7.3.60.0100.00614.80
7.3.50.0030.01014.93
7.3.40.0030.01014.76
7.3.30.0040.00914.95
7.3.20.0060.00716.65
7.3.10.0040.01016.50
7.3.00.0050.00816.70
7.2.330.0160.00316.70
7.2.320.0150.00916.82
7.2.310.0190.00316.85
7.2.300.0060.00916.77
7.2.290.0140.00316.76
7.2.260.0050.01115.23
7.2.250.0110.00715.11
7.2.240.0060.00914.99
7.2.230.0090.00714.96
7.2.220.0090.00615.13
7.2.210.0060.00915.22
7.2.200.0070.00415.05
7.2.190.0030.01114.95
7.2.180.0050.00914.96
7.2.170.0070.00915.11
7.2.160.0030.01415.06
7.2.150.0060.00716.98
7.2.140.0040.01217.03
7.2.130.0040.00917.03
7.2.120.0070.00716.96
7.2.110.0060.01016.91
7.2.100.0050.00816.99
7.2.90.0070.00616.93
7.2.80.0060.00916.94
7.2.70.0050.00817.02
7.2.60.0050.00916.94
7.2.50.0050.01216.81
7.2.40.0080.00716.87
7.2.30.0040.00817.06
7.2.20.0010.01116.91
7.2.10.0070.00616.78
7.2.00.0080.00517.59
7.1.330.0070.00515.85
7.1.320.0050.00815.72
7.1.310.0050.00915.88
7.1.300.0070.00715.90
7.1.290.0030.00915.66
7.1.280.0070.00415.77
7.1.270.0040.01015.81
7.1.260.0040.00615.75
7.1.250.0040.00815.79
7.1.240.0040.01015.75
7.1.230.0020.01115.84
7.1.220.0040.00815.71
7.1.210.0040.01115.85
7.1.200.0030.00915.82
7.1.190.0060.00815.80
7.1.180.0060.00715.79
7.1.170.0040.00515.73
7.1.160.0040.01015.73
7.1.150.0100.00515.65
7.1.140.0070.00615.74
7.1.130.0080.00515.82
7.1.120.0060.00615.76
7.1.110.0010.01115.87
7.1.100.0040.00816.44
7.1.90.0020.00815.72
7.1.80.0020.01015.83
7.1.70.0080.00816.09
7.1.60.0060.00816.79
7.1.50.0040.00716.14
7.1.40.0070.00415.87
7.1.30.0050.00815.63
7.1.20.0060.01115.74
7.1.10.0090.00415.78
7.1.00.0060.02217.37
7.0.330.0060.00715.38
7.0.320.0050.00815.42
7.0.310.0060.00615.40
7.0.300.0070.00515.36
7.0.290.0060.00915.27
7.0.280.0050.00715.38
7.0.270.0050.00715.52
7.0.260.0040.00815.31
7.0.250.0040.01015.54
7.0.240.0050.00615.54
7.0.230.0060.00415.47
7.0.220.0060.00815.49
7.0.210.0070.00715.47
7.0.200.0080.00515.74
7.0.190.0050.00815.45
7.0.180.0110.00315.52
7.0.170.0090.00715.43
7.0.160.0030.01015.42
7.0.150.0040.00815.36
7.0.140.0050.02417.09
7.0.130.0050.00715.45
7.0.120.0090.00315.55
7.0.110.0070.00315.41
7.0.100.0090.00215.41
7.0.90.0050.00815.25
7.0.80.0060.00715.38
7.0.70.0060.00815.39
7.0.60.0030.02616.52
7.0.50.0050.01516.02
7.0.40.0050.02815.19
7.0.30.0100.02615.22
7.0.20.0130.01815.08
7.0.10.0100.02615.19
7.0.00.0020.02915.19
5.6.400.0080.00514.34
5.6.390.0030.00914.63
5.6.380.0090.00514.59
5.6.370.0080.00814.53
5.6.360.0050.01014.34
5.6.350.0070.00714.53
5.6.340.0010.01114.53
5.6.330.0040.00814.52
5.6.320.0050.00814.37
5.6.310.0050.00814.34
5.6.300.0040.00714.34
5.6.290.0080.00414.55
5.6.280.0060.02316.06
5.6.270.0050.01114.51
5.6.260.0060.00614.47
5.6.250.0040.00814.45
5.6.240.0050.00814.44
5.6.230.0050.00914.38
5.6.220.0020.00914.53
5.6.210.0060.02415.95
5.6.200.0050.02515.43
5.6.190.0040.01815.99
5.6.180.1060.01315.99
5.6.170.0080.02016.02
5.6.160.0050.02815.78
5.6.150.0050.02415.42
5.6.140.0070.02315.38
5.6.130.0080.02715.46
5.6.120.0080.01616.19
5.6.110.0050.01916.01
5.6.100.0050.02116.19
5.6.90.0040.02816.15
5.6.80.0040.02115.82
5.6.70.0140.02415.83
5.6.60.0040.00814.34
5.6.50.0070.00714.30
5.6.40.0110.00314.27
5.6.30.0020.01014.28
5.6.20.0070.00714.43
5.6.10.0050.00714.39
5.6.00.0040.01114.38
5.5.380.0020.01314.33
5.5.370.0040.01114.28
5.5.360.0050.00714.35
5.5.350.0050.02515.80
5.5.340.0060.01615.27
5.5.330.0050.02316.00
5.5.320.0120.02115.94
5.5.310.0100.02315.78
5.5.300.0090.02415.33
5.5.290.0080.01815.31
5.5.280.0080.02515.94
5.5.270.0050.02616.02
5.5.260.0060.01716.08
5.5.250.0060.02015.96
5.5.240.0050.02215.71
5.5.230.0060.01014.26
5.5.220.0050.00914.43
5.5.210.0070.00714.26
5.5.200.0090.00314.40
5.5.190.0010.00914.18
5.5.180.0040.01014.13
5.5.170.0080.00614.39
5.5.160.0050.01014.28
5.5.150.0070.00714.39
5.5.140.0040.01214.26
5.5.130.0030.01214.45
5.5.120.0100.00314.25
5.5.110.0070.00514.25
5.5.100.0050.00714.29
5.5.90.0060.00614.20
5.5.80.0070.00614.37
5.5.70.0050.00914.31
5.5.60.0040.00814.02
5.5.50.0080.00614.38
5.5.40.0090.00814.36
5.5.30.0050.01114.32
5.5.20.0050.01014.12
5.5.10.0040.00914.48
5.5.00.0060.00714.35
5.4.450.0100.02013.80
5.4.440.0110.02313.71
5.4.430.0030.02013.79
5.4.420.0070.01913.84
5.4.410.0070.01713.72
5.4.400.0150.02113.57
5.4.390.0130.01513.53
5.4.380.0110.01913.69
5.4.370.0090.01213.60
5.4.360.0060.01613.61
5.4.350.0030.01312.14
5.4.340.0020.01611.91
5.4.330.0010.01011.95
5.4.320.0030.01512.15
5.4.310.0050.01412.07
5.4.300.0050.01212.08
5.4.290.0050.01312.06
5.4.280.0050.01612.06
5.4.270.0030.01512.19
5.4.260.0060.01212.07
5.4.250.0040.01412.14
5.4.240.0050.01412.16
5.4.230.0070.01212.13
5.4.220.0040.01712.03
5.4.210.0060.01312.11
5.4.200.0040.01312.13
5.4.190.0050.01312.02
5.4.180.0050.01112.14
5.4.170.0140.03912.00
5.4.160.0130.02612.13
5.4.150.0140.02412.08
5.4.140.0060.01611.87
5.4.130.0100.02711.96
5.4.120.0080.02111.94
5.4.110.0100.02912.00
5.4.100.0080.01412.07
5.4.90.0090.01412.03
5.4.80.0140.02412.02
5.4.70.0060.01512.06
5.4.60.0060.01711.99
5.4.50.0050.01711.95
5.4.40.0050.01511.83
5.4.30.0080.01611.95
5.4.20.0080.01512.04
5.4.10.0080.01412.00
5.4.00.0170.03411.84
5.3.290.0060.01412.00
5.3.280.0090.01111.88
5.3.270.0080.01511.88
5.3.260.0080.01511.96
5.3.250.0140.02411.90
5.3.240.0070.01511.82
5.3.230.0120.02711.86
5.3.220.0080.01411.89
5.3.210.0060.01711.88
5.3.200.0110.02711.87
5.3.190.0120.02611.90
5.3.180.0120.02411.95
5.3.170.0080.01311.93
5.3.160.0170.02811.96
5.3.150.0060.01611.91
5.3.140.0060.01611.92
5.3.130.0060.01711.93
5.3.120.0110.02611.93
5.3.110.0060.01711.88
5.3.100.0070.03111.73
5.3.90.0110.02611.71
5.3.80.0080.01611.71
5.3.70.0100.02711.65
5.3.60.0090.02911.74
5.3.50.0140.02411.73
5.3.40.0090.01411.72
5.3.30.0080.01311.74
5.3.20.0100.01311.69
5.3.10.0080.02911.53
5.3.00.0090.02011.53
5.2.170.0150.0339.24
5.2.160.0120.0399.24
5.2.150.0310.0819.23
5.2.140.0240.0849.23
5.2.130.0100.0379.20
5.2.120.0120.0359.20
5.2.110.0150.0339.20
5.2.100.0330.0749.20
5.2.90.0090.0389.20
5.2.80.0170.0319.19
5.2.70.0340.0759.19
5.2.60.0110.0369.14
5.2.50.0120.0389.11
5.2.40.0290.0799.09
5.2.30.0090.0419.06
5.2.20.0240.0839.07
5.2.10.0310.0788.96
5.2.00.0150.0318.82
5.1.60.0230.0498.09
5.1.50.0140.0328.10
5.1.40.0160.0588.08
5.1.30.0380.0718.43
5.1.20.0120.0348.46
5.1.10.0140.0358.18
5.1.00.0230.0518.17
5.0.50.0070.0266.66
5.0.40.0080.0236.51
5.0.30.0070.0386.33
5.0.20.0110.0216.31
5.0.10.0060.0276.28
5.0.00.0080.0376.27
4.4.90.0290.0564.78
4.4.80.0080.0164.75
4.4.70.0080.0174.76
4.4.60.0060.0194.75
4.4.50.0160.0694.77
4.4.40.0070.0284.70
4.4.30.0060.0194.75
4.4.20.0100.0154.84
4.4.10.0060.0194.85
4.4.00.0240.0714.76
4.3.110.0320.0544.67
4.3.100.0090.0154.67
4.3.90.0090.0174.63
4.3.80.0180.0774.58
4.3.70.0220.0644.63
4.3.60.0050.0184.63
4.3.50.0080.0164.63
4.3.40.0160.0804.54
4.3.30.0050.0183.34
4.3.20.0040.0193.33
4.3.10.0030.0203.29
4.3.00.0030.0207.00

preferences:
46.6 ms | 401 KiB | 5 Q