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) { foreach ($outputFromFoo as $key => $value) { // other stuff if ($key === $str) { echo "Found $str!"; } } } $result = foo(array('ab', 'cd', '10')); print_r( $result ); 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.3.40.0110.00418.53
8.3.30.0090.00618.61
8.3.20.0080.00020.34
8.3.10.0080.00020.48
8.3.00.0040.00423.35
8.2.170.0080.00822.96
8.2.160.0080.00622.13
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00820.72
8.2.120.0050.00326.35
8.2.110.0070.00321.18
8.2.100.0110.00017.78
8.2.90.0030.00619.05
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0100.00018.05
8.2.50.0040.00418.09
8.2.40.0000.00822.04
8.2.30.0000.00719.43
8.2.20.0000.00717.73
8.2.10.0040.00418.05
8.2.00.0050.00318.03
8.1.270.0000.01422.05
8.1.260.0070.00028.09
8.1.250.0050.00328.09
8.1.240.0100.00722.11
8.1.230.0000.01118.83
8.1.220.0060.00317.77
8.1.210.0000.00818.77
8.1.200.0070.00317.23
8.1.190.0040.00417.36
8.1.180.0050.00318.10
8.1.170.0040.00718.39
8.1.160.0050.00220.71
8.1.150.0040.00418.93
8.1.140.0050.00319.59
8.1.130.0030.00317.63
8.1.120.0000.00717.52
8.1.110.0070.00017.43
8.1.100.0070.00017.38
8.1.90.0050.00317.48
8.1.80.0030.00517.45
8.1.70.0000.00717.43
8.1.60.0000.00717.46
8.1.50.0080.00017.55
8.1.40.0000.00817.54
8.1.30.0000.00917.51
8.1.20.0050.00317.49
8.1.10.0040.00417.61
8.1.00.0040.00417.51
8.0.300.0060.00321.70
8.0.290.0060.00316.63
8.0.280.0030.00318.45
8.0.270.0070.00017.29
8.0.260.0060.00017.16
8.0.250.0000.00716.89
8.0.240.0040.00417.00
8.0.230.0000.00716.94
8.0.220.0040.00416.75
8.0.210.0040.00416.91
8.0.200.0040.00416.82
8.0.190.0030.00516.81
8.0.180.0070.00016.91
8.0.170.0080.00016.88
8.0.160.0070.00016.80
8.0.150.0000.00816.79
8.0.140.0050.00516.86
8.0.130.0030.00313.32
8.0.120.0050.00316.89
8.0.110.0040.00316.91
8.0.100.0040.00416.76
8.0.90.0070.00016.83
8.0.80.0100.00716.83
8.0.70.0040.00416.89
8.0.60.0030.00516.87
8.0.50.0040.00416.86
8.0.30.0130.01017.12
8.0.20.0120.00617.40
8.0.10.0040.00416.97
8.0.00.0090.01116.83
7.4.330.0060.00016.67
7.4.320.0060.00016.60
7.4.300.0000.00616.57
7.4.290.0000.00816.50
7.4.280.0040.00416.54
7.4.270.0040.00716.59
7.4.260.0030.00516.57
7.4.250.0030.00316.56
7.4.240.0040.00416.54
7.4.230.0030.00316.34
7.4.220.0130.00916.53
7.4.210.0040.01516.57
7.4.200.0000.00716.62
7.4.160.0100.01316.45
7.4.150.0100.00717.40
7.4.140.0160.00817.86
7.4.130.0120.00616.47
7.4.120.0150.00616.60
7.4.110.0100.00716.77
7.4.100.0100.01016.59
7.4.90.0080.00816.50
7.4.80.0070.01419.39
7.4.70.0120.00316.34
7.4.60.0100.00716.49
7.4.50.0030.01316.46
7.4.40.0090.00616.57
7.4.30.0100.01416.70
7.4.00.0030.01014.99
7.3.330.0030.00313.35
7.3.320.0050.00013.35
7.3.310.0040.00416.41
7.3.300.0000.00716.36
7.3.290.0080.00716.38
7.3.280.0080.01016.33
7.3.270.0080.00817.40
7.3.260.0150.00416.28
7.3.250.0090.01116.46
7.3.240.0110.00816.40
7.3.230.0110.00716.39
7.3.210.0120.00916.66
7.3.200.0110.00419.39
7.3.190.0100.00616.37
7.3.180.0060.00916.58
7.3.170.0030.01316.37
7.3.160.0080.00816.54
7.3.120.0100.00615.02
7.3.110.0070.01014.87
7.3.100.0090.00314.82
7.3.90.0090.00314.93
7.3.80.0040.01414.89
7.3.70.0030.01314.73
7.3.60.0040.01114.68
7.3.50.0060.00614.53
7.3.40.0060.00614.83
7.3.30.0070.00714.79
7.3.20.0090.00616.81
7.3.10.0040.00716.47
7.3.00.0070.00416.49
7.2.330.0030.01416.57
7.2.320.0060.00916.80
7.2.310.0100.01316.73
7.2.300.0070.01016.69
7.2.290.0060.01116.86
7.2.240.0030.01015.11
7.2.230.0070.00414.68
7.2.220.0060.00614.96
7.2.210.0070.01015.11
7.2.200.0030.00915.06
7.2.190.0030.01015.13
7.2.180.0030.01314.95
7.2.170.0030.01015.03
7.2.160.0070.01014.93
7.2.150.0030.01216.72
7.2.140.0090.00616.95
7.2.130.0030.01316.91
7.2.120.0000.01116.87
7.2.110.0080.00816.79
7.2.100.0040.01116.87
7.2.90.0070.00416.88
7.2.80.0040.01117.04
7.2.70.0000.01616.81
7.2.60.0030.00916.72
7.2.50.0000.01616.73
7.2.40.0060.00916.88
7.2.30.0040.01117.04
7.2.20.0000.00916.92
7.2.10.0000.01216.80
7.2.00.0040.00918.04
7.1.330.0090.00615.75
7.1.320.0070.01015.98
7.1.310.0060.01015.54
7.1.300.0060.00315.81
7.1.290.0060.00315.53
7.1.280.0000.01115.59
7.1.270.0030.00615.90
7.1.260.0040.01115.43
7.1.250.0070.00715.77
7.1.200.0030.01015.88
7.1.100.0060.00617.84
7.1.70.0040.00416.88
7.1.60.0000.01119.40
7.1.50.0090.01216.75
7.1.00.0130.06322.55
7.0.200.0030.00714.95
7.0.60.0300.06320.00
7.0.50.0070.06717.88
7.0.40.0100.08320.12
7.0.30.0230.04020.16
7.0.20.0270.08320.33
7.0.10.0030.04320.09
7.0.00.0070.05020.16
5.6.280.0030.03021.12
5.6.210.0000.04320.47
5.6.200.0070.08718.27
5.6.190.0170.07020.48
5.6.180.0300.05320.65
5.6.170.0130.06020.50
5.6.160.0000.04720.56
5.6.150.0030.04318.15
5.6.140.0070.08018.23
5.6.130.0000.05718.14
5.6.120.0070.04721.13
5.6.110.0100.08321.01
5.6.100.0030.08720.96
5.6.90.0070.03721.09
5.6.80.0100.04320.49
5.5.350.0170.07720.32
5.5.340.0070.08018.04
5.5.330.0170.06320.31
5.5.320.0200.04020.51
5.5.310.0200.04320.25
5.5.300.0100.06017.99
5.5.290.0000.08717.94
5.5.280.0100.04320.65
5.5.270.0100.08320.97
5.5.260.0100.08020.87
5.5.250.0100.07020.69
5.5.240.0170.04320.04

preferences:
54.64 ms | 400 KiB | 5 Q