3v4l.org

run code in 300+ PHP versions simultaneously
<?php function first(/* [(array $array, $key) | $value]... */) { $count = func_num_args(); for ($i = 0; $i < $count - 1; $i++) { $arg = func_get_arg($i); if (!isset($arg)) { continue; } if (is_array($arg)) { $key = func_get_arg($i + 1); if (is_null($key) || is_string($key) || is_int($key) || is_float($key) || is_bool($key)) { if (isset($arg[$key])) { return $arg[$key]; } $i++; continue; } } return $arg; } if ($i < $count) { return func_get_arg($i); } return null; } $test = array(); echo $test ? 'truthy' : 'empty', "\r\n"; echo first(array($test[0], 0), '$test[0][0] is not set'), "\r\n"; echo $test ? 'truthy' : 'empty', "\r\n";

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.0070.00716.75
8.3.50.0120.00821.13
8.3.40.0100.01019.02
8.3.30.0070.00719.09
8.3.20.0070.00020.34
8.3.10.0080.00023.65
8.3.00.0040.00420.87
8.2.180.0120.00916.50
8.2.170.0100.01018.95
8.2.160.0070.00722.96
8.2.150.0000.00824.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00020.89
8.2.110.0060.00322.25
8.2.100.0040.00817.84
8.2.90.0040.00419.31
8.2.80.0040.00419.27
8.2.70.0040.00417.75
8.2.60.0040.00418.03
8.2.50.0060.00318.07
8.2.40.0000.00819.95
8.2.30.0120.00019.30
8.2.20.0000.00817.68
8.2.10.0040.00418.14
8.2.00.0070.00018.12
8.1.280.0100.01025.92
8.1.270.0040.00420.33
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0030.00623.75
8.1.230.0030.00719.13
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0060.00317.22
8.1.190.0000.00817.43
8.1.180.0050.00318.10
8.1.170.0050.00318.57
8.1.160.0000.00718.97
8.1.150.0040.00418.75
8.1.140.0040.00417.41
8.1.130.0000.00717.82
8.1.120.0050.00217.46
8.1.110.0030.00717.32
8.1.100.0000.00717.46
8.1.90.0040.00417.39
8.1.80.0050.00317.50
8.1.70.0000.00717.32
8.1.60.0000.00817.64
8.1.50.0040.00417.41
8.1.40.0030.00617.56
8.1.30.0000.00817.68
8.1.20.0000.00817.55
8.1.10.0090.00017.42
8.1.00.0000.00817.34
8.0.300.0000.00818.90
8.0.290.0050.00316.92
8.0.280.0030.00318.44
8.0.270.0000.00817.30
8.0.260.0030.00317.35
8.0.250.0000.00716.89
8.0.240.0000.00716.90
8.0.230.0040.00417.02
8.0.220.0000.00716.93
8.0.210.0000.00816.90
8.0.200.0060.00016.99
8.0.190.0050.00217.08
8.0.180.0030.00516.86
8.0.170.0040.00416.97
8.0.160.0030.00617.00
8.0.150.0000.00717.02
8.0.140.0040.00416.81
8.0.130.0000.00613.34
8.0.120.0060.00316.82
8.0.110.0050.00316.98
8.0.100.0050.00216.98
8.0.90.0000.00716.83
8.0.80.0030.01316.91
8.0.70.0040.00416.90
8.0.60.0030.00516.98
8.0.50.0050.00216.98
8.0.30.0120.00817.01
8.0.20.0150.00817.40
8.0.10.0040.00417.03
8.0.00.0100.00816.78
7.4.330.0000.00515.03
7.4.320.0000.00616.59
7.4.300.0030.00316.57
7.4.290.0030.00616.45
7.4.280.0000.00716.41
7.4.270.0000.00616.66
7.4.260.0000.00716.39
7.4.250.0080.00016.50
7.4.240.0020.00516.52
7.4.230.0000.00716.55
7.4.220.0210.01516.51
7.4.210.0070.00616.59
7.4.200.0040.00416.60
7.4.160.0030.01216.39
7.4.150.0090.00917.40
7.4.140.0080.01017.86
7.4.130.0100.00816.60
7.4.120.0060.01116.56
7.4.110.0030.01316.57
7.4.100.0110.01116.48
7.4.90.0160.00316.33
7.4.80.0160.00019.39
7.4.70.0050.01316.30
7.4.60.0060.00916.59
7.4.50.0000.00816.20
7.4.40.0110.00916.53
7.4.30.0120.00616.76
7.4.10.0110.00715.27
7.4.00.0080.00814.96
7.3.330.0030.00313.40
7.3.320.0150.00013.45
7.3.310.0030.00316.44
7.3.300.0030.00316.32
7.3.290.0030.00316.40
7.3.280.0070.01116.34
7.3.270.0090.00917.40
7.3.260.0080.00916.42
7.3.250.0110.00816.50
7.3.240.0100.00716.51
7.3.230.0030.01516.68
7.3.210.0090.00916.45
7.3.200.0030.01319.39
7.3.190.0030.01316.39
7.3.180.0080.00816.60
7.3.170.0110.00716.47
7.3.160.0080.00816.45
7.3.130.0070.01314.87
7.3.120.0060.01114.89
7.3.110.0090.00914.94
7.3.100.0030.01114.75
7.3.90.0050.01014.97
7.3.80.0050.00614.84
7.3.70.0030.00914.81
7.3.60.0080.00614.85
7.3.50.0040.01114.90
7.3.40.0050.01114.76
7.3.30.0050.00814.88
7.3.20.0070.00916.74
7.3.10.0050.01016.68
7.3.00.0070.00516.61
7.2.330.0030.01516.72
7.2.320.0110.00716.52
7.2.310.0060.01216.44
7.2.300.0060.01016.46
7.2.290.0080.00916.75
7.2.260.0100.00715.09
7.2.250.0070.01214.80
7.2.240.0100.00814.97
7.2.230.0000.01315.12
7.2.220.0080.00615.14
7.2.210.0080.00515.13
7.2.200.0070.00615.13
7.2.190.0030.01015.22
7.2.180.0040.01015.12
7.2.170.0030.00815.13
7.2.160.0070.01014.85
7.2.150.0050.01116.77
7.2.140.0090.00916.91
7.2.130.0050.01116.93
7.2.120.0080.00817.03
7.2.110.0090.00516.94
7.2.100.0060.00816.96
7.2.90.0080.00516.92
7.2.80.0050.00916.99
7.2.70.0040.00916.87
7.2.60.0080.00616.86
7.2.50.0050.01116.83
7.2.40.0090.00517.00
7.2.30.0090.00916.97
7.2.20.0060.01217.01
7.2.10.0130.00316.99
7.2.00.0030.01117.70
7.1.330.0040.00915.75
7.1.320.0050.00815.82
7.1.310.0060.00615.71
7.1.300.0060.00715.83
7.1.290.0040.01015.79
7.1.280.0040.00915.78
7.1.270.0050.01015.71
7.1.260.0070.00715.74
7.1.250.0100.00515.68
7.1.240.0030.01015.56
7.1.230.0070.00415.96
7.1.220.0070.01015.79
7.1.210.0030.01115.92
7.1.200.0080.00215.71
7.1.190.0060.00315.95
7.1.180.0080.00415.75
7.1.170.0100.00315.85
7.1.160.0090.00615.82
7.1.150.0030.01015.76
7.1.140.0120.00615.75
7.1.130.0110.00515.86
7.1.120.0150.00015.91
7.1.110.0060.00315.93
7.1.100.0060.00716.93
7.1.90.0090.00615.55
7.1.80.0140.00315.82
7.1.70.0040.00616.61
7.1.60.0070.01217.86
7.1.50.0050.01516.12
7.1.40.0070.00715.93
7.1.30.0040.01115.77
7.1.20.0040.00715.79
7.1.10.0060.00615.74
7.1.00.0060.04219.05
7.0.330.0080.00615.42
7.0.320.0040.00815.49
7.0.310.0100.00615.41
7.0.300.0030.01015.48
7.0.290.0000.01015.46
7.0.280.0060.00615.36
7.0.270.0080.00415.44
7.0.260.0110.00415.08
7.0.250.0070.00415.40
7.0.240.0090.00315.60
7.0.230.0040.01215.57
7.0.220.0060.00915.46
7.0.210.0080.00415.51
7.0.200.0070.00616.03
7.0.190.0060.00915.61
7.0.180.0110.00315.49
7.0.170.0060.00615.54
7.0.160.0070.00315.45
7.0.150.0040.01215.41
7.0.140.0070.00715.54
7.0.130.0100.00715.43
7.0.120.0110.00415.18
7.0.110.0060.00615.50
7.0.100.0040.00815.54
7.0.90.0100.00315.52
7.0.80.0030.01315.27
7.0.70.0050.00515.45
7.0.60.0050.04617.62
7.0.50.0030.02316.81
7.0.40.0080.04316.74
7.0.30.0160.03816.89
7.0.20.0180.03416.83
7.0.10.0140.04216.84
7.0.00.0070.03916.91
5.6.400.0040.00414.52
5.6.390.0030.01414.49
5.6.380.0060.00914.45
5.6.370.0040.01114.55
5.6.360.0030.00814.73
5.6.350.0030.00914.11
5.6.340.0030.01014.36
5.6.330.0080.00814.61
5.6.320.0100.00314.65
5.6.310.0100.00314.54
5.6.300.0150.00014.13
5.6.290.0060.00914.70
5.6.280.0020.04617.73
5.6.270.0000.01014.43
5.6.260.0080.00614.33
5.6.250.0030.01214.50
5.6.240.0070.00714.25
5.6.230.0060.00814.63
5.6.220.0000.01314.23
5.6.210.0070.04517.48
5.6.200.0080.04316.38
5.6.190.0090.04517.52
5.6.180.0200.03817.63
5.6.170.0170.04717.51
5.6.160.0090.03317.52
5.6.150.0080.04516.13
5.6.140.0100.04116.33
5.6.130.0050.02316.51
5.6.120.0050.03017.60
5.6.110.0050.04417.71
5.6.100.0050.04817.68
5.6.90.0010.03817.58
5.6.80.0090.03317.21
5.6.70.0040.00414.29
5.6.60.0030.01014.25
5.6.50.0130.00314.43
5.6.40.0070.01014.23
5.6.30.0030.01314.32
5.6.20.0060.00614.30
5.6.10.0000.01214.30
5.6.00.0000.01414.36
5.5.380.0040.01114.48
5.5.370.0060.01014.71
5.5.360.0000.01114.29
5.5.350.0050.02317.32
5.5.340.0100.04216.27
5.5.330.0080.03717.41
5.5.320.1680.02717.49
5.5.310.0080.02917.28
5.5.300.0020.03016.14
5.5.290.0100.01816.17
5.5.280.0070.03017.68
5.5.270.0030.02317.47
5.5.260.0080.02317.49
5.5.250.0000.04417.53
5.5.240.0030.03017.37
5.5.230.0090.00614.31
5.5.220.0050.00514.35
5.5.210.0040.01114.37
5.5.200.0030.01014.38
5.5.190.0120.00314.36
5.5.180.0070.00714.44
5.5.170.0060.00314.32
5.5.160.0070.00714.43
5.5.150.0030.01014.45
5.5.140.0090.00314.48
5.5.130.0000.00914.40
5.5.120.0060.01214.52
5.5.110.0040.01114.56
5.5.100.0110.00414.50
5.5.90.0060.00614.31
5.5.80.0060.00314.40
5.5.70.0040.00714.24
5.5.60.0030.00614.29
5.5.50.0030.00714.21
5.5.40.0030.01014.47
5.5.30.0120.00414.32
5.5.20.0060.00614.39
5.5.10.0030.00913.90
5.5.00.0030.00714.29
5.4.450.0570.02715.68
5.4.440.0400.03315.81
5.4.430.0580.03315.82
5.4.420.0060.03115.72
5.4.410.0130.03015.45
5.4.400.0080.02815.40
5.4.390.0060.03815.27
5.4.380.0120.03715.38
5.4.370.0020.04015.41
5.4.360.0070.03815.38
5.4.350.0120.02715.22
5.4.340.0120.02515.39
5.4.330.0070.00311.98
5.4.320.0080.04115.27
5.4.310.0090.02815.36
5.4.300.0080.02815.28
5.4.290.0110.02615.22
5.4.280.0050.03115.30
5.4.270.0090.02815.39
5.4.260.0100.02615.38
5.4.250.0090.03015.27
5.4.240.0130.02315.24
5.4.230.0020.03515.33
5.4.220.0100.02815.35
5.4.210.0050.04015.33
5.4.200.0100.02314.28
5.4.190.0090.02915.39
5.4.180.0100.02715.23
5.4.170.0080.03215.37
5.4.160.0130.02315.23
5.4.150.0050.03015.35
5.4.140.0060.03114.21
5.4.130.0080.03514.16
5.4.120.0070.02814.14
5.4.110.0030.03314.13
5.4.100.0080.02714.14
5.4.90.0070.02814.14
5.4.80.0070.03014.21
5.4.70.0080.02814.14
5.4.60.0110.03114.08
5.4.50.0080.02814.07
5.4.40.0080.02814.12
5.4.30.0020.03014.12
5.4.20.0100.02614.14
5.4.10.0050.02914.10
5.4.00.0080.02313.82
5.3.290.0030.06014.69
5.3.280.0170.04314.79
5.3.270.0070.05714.63
5.3.260.0100.05014.77
5.3.250.0030.05714.64
5.3.240.0070.05314.70
5.3.230.0070.05714.64
5.3.220.0030.05714.61
5.3.210.0100.05014.61
5.3.200.0130.04714.70
5.3.190.0070.05314.57
5.3.180.0070.05314.58
5.3.170.0170.04314.61
5.3.160.0130.05714.77
5.3.150.0230.05314.66
5.3.140.0000.06714.58
5.3.130.0170.07014.65
5.3.120.0170.06714.57
5.3.110.0070.05714.59
5.3.100.0070.05714.14
5.3.90.0030.06014.16
5.3.80.0030.06014.02
5.3.70.0000.06014.05
5.3.60.0170.05014.12
5.3.50.0170.04714.02
5.3.40.0000.06014.05
5.3.30.0100.05014.04
5.3.20.0030.05313.86
5.3.10.0100.04713.75
5.3.00.0100.05013.64
5.2.170.0070.04011.18
5.2.160.0100.04711.14
5.2.150.0030.04311.17
5.2.140.0070.04011.14
5.2.130.0100.03711.21
5.2.120.0030.04311.21
5.2.110.0070.04011.17
5.2.100.0100.03711.31
5.2.90.0000.04711.21
5.2.80.0070.04311.15
5.2.70.0030.04711.13
5.2.60.0100.04011.27
5.2.50.0070.04311.13
5.2.40.0200.02711.02
5.2.30.0130.03310.97
5.2.20.0000.05011.14
5.2.10.0130.03010.86
5.2.00.0070.04010.94
5.1.60.0030.03310.00
5.1.50.0130.02710.18
5.1.40.0030.03710.05
5.1.30.0100.03310.44
5.1.20.0070.03310.50
5.1.10.0030.03710.27
5.1.00.0030.03710.10
5.0.50.0070.0238.58
5.0.40.0030.0278.57
5.0.30.0100.0378.45
5.0.20.0070.0278.21
5.0.10.0030.0308.19
5.0.00.0130.0438.29
4.4.90.0070.0275.95
4.4.80.0030.0205.98
4.4.70.0000.0235.92
4.4.60.0030.0205.91
4.4.50.0030.0275.92
4.4.40.0030.0335.89
4.4.30.0000.0235.93
4.4.20.0030.0235.96
4.4.10.0100.0206.09
4.4.00.0030.0335.95
4.3.110.0000.0275.87
4.3.100.0070.0175.84
4.3.90.0000.0235.93
4.3.80.0000.0375.79
4.3.70.0030.0205.91
4.3.60.0000.0235.81
4.3.50.0000.0235.89
4.3.40.0000.0375.76
4.3.30.0000.0234.68
4.3.20.0000.0234.68
4.3.10.0000.0234.54
4.3.00.0130.01316.07

preferences:
54.96 ms | 401 KiB | 5 Q