3v4l.org

run code in 300+ PHP versions simultaneously
<?php function namedParams (array $params, array $defaults){ $params += $defaults; $allowedKeys = array_keys($defaults); $isUnexpected = array_filter($params, function ($k) use ($allowedKeys){ return !in_array($k, $allowedKeys); }, ARRAY_FILTER_USE_KEY); if(!empty($isUnexpected)){ throw new InvalidArgumentException('Unexpected parameters: '.implode(',',array_keys($isUnexpected))); } return $params; } function test (array $params){ //we can try ... and catch any problems if we want, but to keep it simple, we can just do this. //These and only these params are expected. Plus, we give them default values. $paramsProcessed = namedParams($params,[ 'name' => 'Unknown', 'sex' => 'man', 'something' => NULL, ]); var_dump($paramsProcessed); } test(['name' => "Konrad"]);

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.0110.00816.74
8.5.00.0130.01020.20
8.4.150.0010.00114.05
8.4.140.0120.00917.84
8.4.130.0040.00417.79
8.4.120.0030.00620.57
8.4.110.0100.01122.38
8.4.100.0120.00917.75
8.4.90.0110.01020.59
8.4.80.0100.00918.82
8.4.70.0050.00419.16
8.4.60.0080.00518.72
8.4.50.0110.00919.46
8.4.40.0170.00319.28
8.4.30.0130.00719.58
8.4.20.0180.00317.48
8.4.10.0070.00319.20
8.3.280.0110.00918.59
8.3.270.0090.01016.38
8.3.260.0090.01016.69
8.3.250.0120.00718.80
8.3.240.0090.00916.54
8.3.230.0080.01216.58
8.3.220.0050.00318.93
8.3.210.0050.00416.63
8.3.200.0040.00516.50
8.3.190.0090.01016.50
8.3.180.0080.00916.92
8.3.170.0090.00918.67
8.3.160.0090.00918.28
8.3.150.0130.00616.61
8.3.140.0130.00619.06
8.3.130.0030.00916.67
8.3.120.0070.00418.79
8.3.110.0190.00020.94
8.3.100.0140.00716.58
8.3.90.0060.01220.34
8.3.80.0060.00318.43
8.3.70.0090.00616.63
8.3.60.0040.01818.20
8.3.50.0080.00718.21
8.3.40.0040.01118.80
8.3.30.0070.00718.72
8.3.20.0070.00021.93
8.3.10.0050.00323.53
8.3.00.0040.00417.74
8.2.290.0130.00720.34
8.2.280.0120.00618.57
8.2.270.0060.01216.74
8.2.260.0140.00416.52
8.2.250.0050.00316.61
8.2.240.0060.00318.80
8.2.230.0030.00622.58
8.2.220.0000.00924.06
8.2.210.0070.00326.77
8.2.200.0030.00618.25
8.2.190.0120.00616.75
8.2.180.0110.00718.05
8.2.170.0000.01422.96
8.2.160.0070.00719.33
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0000.00822.15
8.2.120.0040.00426.35
8.2.110.0070.01020.61
8.2.100.0040.00818.03
8.2.90.0000.00817.84
8.2.80.0080.00019.16
8.2.70.0030.00517.75
8.2.60.0030.00617.93
8.2.50.0030.00518.10
8.2.40.0030.00520.46
8.2.30.0080.00019.38
8.2.20.0060.00318.22
8.2.10.0030.00618.07
8.2.00.0000.00718.11
8.1.330.0100.00921.89
8.1.320.0120.01117.77
8.1.310.0190.00018.05
8.1.300.0000.00819.98
8.1.290.0150.00418.88
8.1.280.0100.00725.92
8.1.270.0030.00518.92
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0100.00023.92
8.1.230.0110.00023.86
8.1.220.0030.00517.74
8.1.210.0040.00418.79
8.1.200.0030.00617.35
8.1.190.0080.00017.35
8.1.180.0030.00618.10
8.1.170.0000.00818.52
8.1.160.0040.00418.89
8.1.150.0030.00618.89
8.1.140.0000.00719.60
8.1.130.0000.00717.47
8.1.120.0020.00517.44
8.1.110.0000.00717.36
8.1.100.0030.00517.45
8.1.90.0000.00917.45
8.1.80.0050.00217.47
8.1.70.0040.00417.41
8.1.60.0030.00517.56
8.1.50.0040.00417.42
8.1.40.0060.00617.52
8.1.30.0030.00517.55
8.1.20.0000.00717.63
8.1.10.0000.00717.38
8.1.00.0030.00517.29
8.0.300.0040.00419.93
8.0.290.0000.00816.88
8.0.280.0070.00018.45
8.0.270.0030.00317.30
8.0.260.0000.00816.80
8.0.250.0070.00017.02
8.0.240.0070.00017.08
8.0.230.0030.00316.87
8.0.220.0030.00316.86
8.0.210.0040.00416.91
8.0.200.0050.00216.89
8.0.190.0070.00316.98
8.0.180.0030.00717.02
8.0.170.0040.00417.03
8.0.160.0000.00716.86
8.0.150.0000.00716.91
8.0.140.0050.00216.96
8.0.130.0000.00613.43
8.0.120.0050.00216.87
8.0.110.0030.00316.84
8.0.100.0000.00716.96
8.0.90.0040.00416.82
8.0.80.0060.00916.95
8.0.70.0040.00416.95
8.0.60.0030.00616.94
8.0.50.0050.00316.99
8.0.30.0060.01217.15
8.0.20.0130.00717.40
8.0.10.0000.00716.86
8.0.00.0120.00616.86
7.4.330.0000.00515.55
7.4.320.0030.00316.60
7.4.300.0000.00616.51
7.4.290.0000.00816.64
7.4.280.0040.00416.55
7.4.270.0040.00416.52
7.4.260.0000.00716.48
7.4.250.0040.00416.43
7.4.240.0030.00516.53
7.4.230.0000.00616.50
7.4.220.0110.00716.58
7.4.210.0060.00916.45
7.4.200.0050.00216.51
7.4.160.0080.00716.54
7.4.150.0080.00917.40
7.4.140.0090.01517.86
7.4.130.0090.00916.63
7.4.120.0130.00816.56
7.4.110.0120.01016.52
7.4.100.0100.00716.65
7.4.90.0090.00916.44
7.4.80.0030.01519.39
7.4.70.0070.01016.38
7.4.60.0120.00316.39
7.4.50.0070.01116.50
7.4.40.0040.01316.43
7.4.30.0100.00616.42
7.4.00.0090.00714.91
7.3.330.0000.00813.29
7.3.320.0040.00413.39
7.3.310.0070.00316.39
7.3.300.0030.00416.40
7.3.290.0080.00816.33
7.3.280.0100.00916.31
7.3.270.0060.01217.40
7.3.260.0040.01416.52
7.3.250.0070.01016.42
7.3.240.0110.00816.38
7.3.230.0150.00316.48
7.3.210.0060.01116.72
7.3.200.0130.00316.69
7.3.190.0090.00916.42
7.3.180.0060.00916.68
7.3.170.0030.01816.29
7.3.160.0030.01316.34
7.3.120.0030.01514.80
7.3.110.0140.00015.07
7.3.100.0080.00814.86
7.3.90.0000.01114.90
7.3.80.0070.00414.83
7.3.70.0060.00314.98
7.3.60.0060.00915.04
7.3.50.0070.00414.88
7.3.40.0070.00714.71
7.3.30.0090.00314.52
7.3.20.0090.00016.75
7.3.10.0120.00316.85
7.3.00.0090.00616.80
7.2.330.0040.01316.58
7.2.320.0040.01316.44
7.2.310.0120.00616.78
7.2.300.0070.01016.67
7.2.290.0040.01816.75
7.2.250.0100.01014.92
7.2.240.0070.01115.14
7.2.230.0100.00714.90
7.2.220.0070.00415.12
7.2.210.0080.00315.21
7.2.200.0000.01015.18
7.2.190.0070.01015.08
7.2.180.0030.00915.03
7.2.170.0100.00614.95
7.2.60.0090.00316.82
7.1.330.0000.01415.88
7.1.320.0080.00315.86
7.1.310.0030.00815.49
7.1.300.0060.00615.93
7.1.290.0000.01115.48
7.1.280.0030.01015.84
7.1.270.0000.01315.89
7.1.260.0040.00415.86
7.1.200.0070.00315.63
7.1.70.0070.00417.17
7.1.60.0030.00817.02
7.1.50.1030.01333.00
7.1.40.0500.01732.46
7.1.30.0870.01332.52
7.1.20.0870.02032.63
7.1.10.0570.00714.67
7.1.00.0600.01314.69
7.0.200.0060.01316.83
7.0.190.1000.01714.84
7.0.180.0600.00714.32
7.0.170.0600.00714.15
7.0.160.0700.01014.31
7.0.150.0400.01014.36
7.0.140.0470.01314.43
7.0.130.0430.01014.64
7.0.120.0370.01314.60
7.0.110.0570.00014.38
7.0.100.0570.00714.41
7.0.90.0370.01714.47
7.0.80.0370.01714.52
7.0.70.0400.01014.64
7.0.60.1130.01014.04
7.0.50.0400.00714.43
7.0.40.0470.01314.54
7.0.30.0370.01014.39
7.0.20.0370.00714.56
7.0.10.0330.01014.55
7.0.00.0330.01314.47

preferences:
40.68 ms | 403 KiB | 5 Q