3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /** * Write a function that accepts an array of strings and return another array * with strings in the input array set as keys. * * @param string[] $arrOfStrings An array of strings. * @return array Another array with strings in the input array set as keys. */ function foo(array $arrOfStrings): array { return array_fill_keys(array_filter($arrOfStrings, 'is_string'), null); } /** * Now write another function that accepts the output of the previous function, * as first argument and another string as second argument. In this function, * assume that you have some reason to iterate over the the input array using * foreach, key => value format. In every iteration, in addition to other stuff, * you also have to check if the key is equal to the input string (the second * parameter of this function), and if they match do some stuff.... * * @param array $outputFromFoo The output from {@link foo()}. */ function bar(array $outputFromFoo, string $str) { array_walk($outputFromFoo, function ($value, $key) use ($str) { if ($key === $str || (is_int($key) && $key == $str)) { echo "Found $str!"; } }); } $result = foo(array('ab', 'cd', '10')); bar($result, '10');

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.5.10.0130.00420.23
8.5.00.0140.00719.94
8.4.160.0140.00919.63
8.4.150.0020.00114.05
8.4.140.0110.01017.31
8.4.130.0100.01017.79
8.4.120.0080.01220.67
8.4.110.0140.00722.63
8.4.100.0120.00917.91
8.4.90.0090.01018.63
8.4.80.0110.01017.95
8.4.70.0120.00817.82
8.4.60.0120.01018.66
8.4.50.0110.00520.54
8.4.40.0110.00918.02
8.4.30.0060.01317.37
8.4.20.0140.00717.73
8.4.10.0170.00317.46
8.3.280.0100.01020.81
8.3.270.0090.01116.48
8.3.260.0120.00716.70
8.3.250.0090.00818.97
8.3.240.0060.00216.50
8.3.230.0070.01116.33
8.3.220.0100.00819.21
8.3.210.0050.00316.59
8.3.200.0070.00216.82
8.3.190.0050.00318.87
8.3.180.0080.01116.59
8.3.170.0100.00719.11
8.3.160.0110.00717.17
8.3.150.0130.00616.93
8.3.140.0040.00416.61
8.3.130.0080.00018.25
8.3.120.0060.00320.61
8.3.110.0040.00418.42
8.3.100.0060.00318.40
8.3.90.0070.00716.50
8.3.80.0090.00018.30
8.3.70.0090.00618.30
8.3.60.0090.00616.38
8.3.50.0050.01621.98
8.3.40.0120.00918.67
8.3.30.0110.00418.68
8.3.20.0000.00720.34
8.3.10.0110.00018.56
8.3.00.0040.00421.81
8.2.290.0040.00520.45
8.2.280.0100.00920.40
8.2.270.0130.00719.06
8.2.260.0050.00516.93
8.2.250.0040.00417.50
8.2.240.0100.00018.85
8.2.230.0030.00620.94
8.2.220.0030.00624.06
8.2.210.0100.00026.77
8.2.200.0100.00018.29
8.2.190.0110.00418.54
8.2.180.0080.00816.35
8.2.170.0150.00322.96
8.2.160.0130.00322.07
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00420.69
8.2.120.0080.00026.35
8.2.110.0070.00420.99
8.2.100.0120.00017.72
8.2.90.0030.00519.09
8.2.80.0030.00517.97
8.2.70.0030.00617.75
8.2.60.0070.00317.93
8.2.50.0030.00618.07
8.2.40.0000.00918.09
8.2.30.0030.00617.95
8.2.20.0000.00717.60
8.2.10.0000.00718.04
8.2.00.0050.00317.94
8.1.330.0100.00921.93
8.1.320.0160.00716.16
8.1.310.0110.00416.73
8.1.300.0000.00816.35
8.1.290.0040.00418.88
8.1.280.0150.00725.92
8.1.270.0100.01022.06
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0030.00622.61
8.1.230.0040.00720.95
8.1.220.0040.00417.79
8.1.210.0030.00518.77
8.1.200.0090.00017.36
8.1.190.0050.00317.22
8.1.180.0090.00018.10
8.1.170.0040.00418.52
8.1.160.0060.00318.90
8.1.150.0000.00718.82
8.1.140.0060.00319.59
8.1.130.0040.00417.61
8.1.120.0040.00317.50
8.1.110.0060.00317.46
8.1.100.0000.00717.38
8.1.90.0000.00717.50
8.1.80.0020.00517.38
8.1.70.0030.00317.42
8.1.60.0040.00417.57
8.1.50.0050.00517.44
8.1.40.0000.00817.54
8.1.30.0000.00817.63
8.1.20.0040.00417.47
8.1.10.0040.00417.49
8.1.00.0040.00417.59
8.0.300.0000.00718.77
8.0.290.0000.00716.63
8.0.280.0000.00718.46
8.0.270.0080.00017.23
8.0.260.0080.00017.25
8.0.250.0000.00716.93
8.0.240.0060.00016.89
8.0.230.0000.00716.95
8.0.220.0050.00616.86
8.0.210.0040.00416.92
8.0.200.0030.00316.97
8.0.190.0000.00716.94
8.0.180.0040.00416.92
8.0.170.0050.00316.82
8.0.160.0040.00416.97
8.0.150.0040.00416.81
8.0.140.0070.00016.71
8.0.130.0030.00313.34
8.0.120.0040.00416.91
8.0.110.0070.00016.80
8.0.100.0000.00716.80
8.0.90.0040.00416.71
8.0.80.0110.00416.88
8.0.70.0000.00816.79
8.0.60.0000.00716.71
8.0.50.0040.00416.96
8.0.30.0130.00316.97
8.0.20.0130.00617.40
8.0.10.0080.00016.91
8.0.00.0080.01016.81
7.4.330.0050.00016.69
7.4.320.0000.00816.52
7.4.300.0030.00316.52
7.4.290.0030.00316.50
7.4.280.0000.00816.51
7.4.270.0000.00816.50
7.4.260.0030.00316.55
7.4.250.0000.00816.60
7.4.240.0030.00316.54
7.4.230.0040.00416.31
7.4.220.0110.01516.62
7.4.210.0060.01116.60
7.4.200.0070.00016.53
7.4.160.0060.00916.49
7.4.150.0060.01217.40
7.4.140.0150.00717.86
7.4.130.0100.01216.59
7.4.120.0120.00716.46
7.4.110.0030.01316.61
7.4.100.0000.01716.43
7.4.90.0080.01116.65
7.4.80.0070.01019.39
7.4.70.0180.02116.52
7.4.60.0030.01416.51
7.4.50.0040.01116.40
7.4.40.0100.00716.43
7.4.30.0040.01916.60
7.4.10.0030.01615.07
7.4.00.0050.01215.06
7.3.330.0030.00313.30
7.3.320.0070.00013.16
7.3.310.0040.00416.44
7.3.300.0070.00016.39
7.3.290.0050.00216.37
7.3.280.0120.00416.36
7.3.270.0070.01117.40
7.3.260.0160.00816.38
7.3.250.0130.00716.54
7.3.240.0100.01016.61
7.3.230.0070.01016.44
7.3.210.0070.01016.40
7.3.200.0090.00619.39
7.3.190.0100.00716.44
7.3.180.0060.01016.51
7.3.170.0130.00616.48
7.3.160.0080.01516.59
7.3.130.0000.01814.75
7.3.120.0090.00914.53
7.3.110.0100.01014.89
7.3.100.0070.00714.96
7.3.90.0060.01114.90
7.3.80.0040.00414.94
7.3.70.0090.00314.62
7.3.60.0040.01114.72
7.3.50.0000.00914.87
7.3.40.0110.00014.68
7.3.30.0070.01315.01
7.3.20.0060.01216.86
7.3.10.0040.00916.73
7.3.00.0070.00716.37
7.2.330.0090.00916.80
7.2.320.0070.01016.80
7.2.310.0090.00916.55
7.2.300.0140.00316.71
7.2.290.0040.01216.64
7.2.260.0040.01515.21
7.2.250.0100.00314.94
7.2.240.0070.00714.76
7.2.230.0060.00915.29
7.2.220.0030.00915.29
7.2.210.0030.00915.18
7.2.200.0080.00615.07
7.2.190.0060.00915.15
7.2.180.0080.00815.11
7.2.170.0050.00515.13
7.2.160.0070.00714.96
7.2.150.0120.00616.72
7.2.140.0060.01016.94
7.2.130.0030.01016.86
7.2.120.0110.00517.01
7.2.110.0060.00616.81
7.2.100.0030.01116.88
7.2.90.0070.00616.87
7.2.80.0050.00816.88
7.2.70.0070.00717.08
7.2.60.0030.01216.93
7.2.50.0080.00816.97
7.2.40.0080.01016.85
7.2.30.0110.00517.02
7.2.20.0090.01116.84
7.2.10.0040.00816.93
7.2.00.0050.01117.88
7.1.330.0100.00316.05
7.1.320.0060.00915.91
7.1.310.0060.00615.69
7.1.300.0030.01015.95
7.1.290.0060.00315.92
7.1.280.0060.00615.84
7.1.270.0140.00315.58
7.1.260.0000.00915.55
7.1.250.0020.01015.80
7.1.240.0060.00915.81
7.1.230.0060.00915.70
7.1.220.0070.01115.71
7.1.210.0030.01015.88
7.1.200.0090.00415.88
7.1.190.0110.00715.85
7.1.180.0140.00315.74
7.1.170.0090.00615.95
7.1.160.0000.01215.83
7.1.150.0090.00315.84
7.1.140.0040.01215.61
7.1.130.0030.00815.68
7.1.120.0060.00615.93
7.1.110.0060.00615.92
7.1.100.0020.00816.78
7.1.90.0090.00315.63
7.1.80.0060.00615.81
7.1.70.0020.00616.55
7.1.60.0070.00917.62
7.1.50.0050.01216.47
7.1.40.0070.00415.68
7.1.30.0070.00715.47
7.1.20.0030.01215.97
7.1.10.0000.00915.66
7.1.00.0030.04319.08
7.0.330.0100.00615.34
7.0.320.0100.00315.47
7.0.310.0030.01415.50
7.0.300.0080.00815.07
7.0.290.0030.00615.18
7.0.280.0060.00915.55
7.0.270.0100.00315.41
7.0.260.0100.00315.47
7.0.250.0000.01115.61
7.0.240.0040.00415.34
7.0.230.0070.00715.59
7.0.220.0090.00315.41
7.0.210.0030.00515.16
7.0.200.0040.00716.07
7.0.190.0080.00415.63
7.0.180.0040.00715.37
7.0.170.0000.00815.20
7.0.160.0000.01315.43
7.0.150.0030.00915.48
7.0.140.0060.00615.44
7.0.130.0100.00615.44
7.0.120.0000.00915.47
7.0.110.0040.01115.32
7.0.100.0040.01115.36
7.0.90.0070.00715.10
7.0.80.0040.00915.17
7.0.70.0060.03618.46
7.0.60.0100.04018.78
7.0.50.0070.03518.94
7.0.40.0020.04616.66
7.0.30.0050.04416.83
7.0.20.0060.04316.74
7.0.10.0040.04616.83
7.0.00.0030.03716.76
5.6.400.0030.01413.98
5.6.390.0090.00314.11
5.6.380.0060.00313.96
5.6.370.0070.00714.32
5.6.360.0070.00313.96
5.6.350.0000.01014.06
5.6.340.0000.01613.89
5.6.330.0000.01114.39
5.6.320.0030.00613.99
5.6.310.0030.00714.15
5.6.300.0110.00414.04
5.6.290.0000.01214.45
5.6.280.0050.01717.63
5.6.270.0030.00714.31
5.6.260.0040.01114.25
5.6.250.0060.00314.31
5.6.240.0000.01414.34
5.6.230.0030.01014.03
5.6.220.0110.03117.38
5.6.210.0100.04217.37
5.6.200.0100.04217.61
5.6.190.0100.04217.62
5.6.180.0110.03017.50
5.6.170.0030.04117.78
5.6.160.0040.03517.61
5.6.150.0080.02817.63
5.6.140.0090.04317.62
5.6.130.0040.04617.57
5.6.120.0030.04917.62
5.6.110.0050.02817.56
5.6.100.0080.04517.48
5.6.90.0050.04417.52
5.6.80.0100.04317.36
5.6.70.0050.04217.31
5.6.60.0070.03617.18
5.6.50.0070.04217.36
5.6.40.0050.04217.24
5.6.30.0020.04617.22
5.6.20.0070.04517.17
5.6.10.0050.03917.21
5.6.00.0030.03117.13
5.5.380.0060.00913.96
5.5.370.0060.00614.02
5.5.360.0100.03717.19
5.5.350.0060.04217.19
5.5.340.0040.04117.48
5.5.330.0050.03417.42
5.5.320.0110.03817.36
5.5.310.0110.03817.63
5.5.300.0060.02517.37
5.5.290.0050.04517.35
5.5.280.0070.04517.42
5.5.270.0050.02517.43
5.5.260.0020.05117.26
5.5.250.0020.05117.39
5.5.240.0100.04017.08
5.5.230.0050.02917.08
5.5.220.0050.04016.89
5.5.210.0060.04216.96
5.5.200.0080.03816.99
5.5.190.0030.04217.18
5.5.180.0060.04117.13
5.5.170.0070.00713.98
5.5.160.0070.02816.99
5.5.150.0030.02917.19
5.5.140.0080.04517.15
5.5.130.0070.03717.05
5.5.120.0030.04617.04
5.5.110.0070.04317.12
5.5.100.0050.04517.07
5.5.90.0070.04217.14
5.5.80.0080.04317.14
5.5.70.0050.04717.15
5.5.60.0070.04117.00
5.5.50.0100.03317.10
5.5.40.0170.02917.13
5.5.30.0030.04717.13
5.5.20.0090.03317.00
5.5.10.0120.02717.16
5.5.00.0060.02417.10

preferences:
45.88 ms | 403 KiB | 5 Q