3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_flatten($array, $result = []) { if(!is_array($array)) { return false; } foreach($array as $key => $value) { if(is_array($value)) { $result = array_flatten($value, $result); } else { $result[$key] = $value; } } return $result; } $allowedKeys = [ 'firstname', 'middlename', 'street', 'lastname', 'housenumber', ]; $userdata = [ 'firstname' => 'first', 'middlename' => 'middle', 'lastname' => 'last', 'address' => [ 'street' => 'streeeeeet', 'housenumber' => '10' ] ]; $addresses = array_flatten($userdata); foreach($userdata as $key => $value) { if(!in_array($key, $allowedKeys)) { unset($userdata[$key]); } } var_dump($addresses);

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.01116.75
8.3.50.0180.00316.52
8.3.40.0120.00318.85
8.3.30.0100.01018.71
8.3.20.0000.00720.36
8.3.10.0090.00022.14
8.3.00.0060.00323.61
8.2.180.0100.00716.75
8.2.170.0040.01122.96
8.2.160.0070.00720.35
8.2.150.0030.00624.18
8.2.140.0050.00324.66
8.2.130.0000.00526.16
8.2.120.0070.00019.89
8.2.110.0060.00322.07
8.2.100.0090.00617.72
8.2.90.0000.00817.75
8.2.80.0000.00818.91
8.2.70.0050.00517.75
8.2.60.0090.00018.16
8.2.50.0090.00018.07
8.2.40.0030.00518.22
8.2.30.0000.00718.12
8.2.20.0040.00418.17
8.2.10.0040.00418.12
8.2.00.0040.00418.02
8.1.280.0090.00625.92
8.1.270.0000.00721.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0040.00420.32
8.1.230.0110.00017.89
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0070.00317.36
8.1.190.0000.00817.36
8.1.180.0030.00619.31
8.1.170.0080.00018.59
8.1.160.0050.00318.86
8.1.150.0080.00020.07
8.1.140.0040.00419.57
8.1.130.0040.00417.48
8.1.120.0040.00417.47
8.1.110.0000.00817.33
8.1.100.0050.00217.46
8.1.90.0060.00317.52
8.1.80.0060.00317.40
8.1.70.0030.00317.36
8.1.60.0000.01017.64
8.1.50.0050.00217.50
8.1.40.0000.00817.55
8.1.30.0020.00517.61
8.1.20.0000.00717.56
8.1.10.0040.00417.45
8.1.00.0040.00417.46
8.0.300.0000.00718.77
8.0.290.0000.00716.75
8.0.280.0040.00418.36
8.0.270.0030.00317.16
8.0.260.0000.00716.78
8.0.250.0030.00316.91
8.0.240.0060.00316.96
8.0.230.0000.00816.94
8.0.220.0040.00316.91
8.0.210.0000.00816.88
8.0.200.0030.00316.96
8.0.190.0040.00416.92
8.0.180.0060.00316.82
8.0.170.0050.00316.92
8.0.160.0030.00616.85
8.0.150.0040.00416.82
8.0.140.0040.00416.76
8.0.130.0030.00313.40
8.0.120.0050.00316.80
8.0.110.0080.00016.84
8.0.100.0070.00016.74
8.0.90.0040.00416.99
8.0.80.0040.01116.89
8.0.70.0070.00016.92
8.0.60.0050.00316.92
8.0.50.0070.00017.00
8.0.30.0100.01317.03
8.0.20.0070.01317.40
8.0.10.0070.00017.05
8.0.00.0040.01416.92
7.4.330.0040.00015.55
7.4.320.0030.00316.56
7.4.300.0030.00316.41
7.4.290.0000.00716.53
7.4.280.0070.00016.49
7.4.270.0000.00716.56
7.4.260.0040.00416.48
7.4.250.0000.00816.48
7.4.240.0000.00816.51
7.4.230.0070.00016.41
7.4.220.0050.00316.40
7.4.210.0030.01016.61
7.4.200.0040.00416.50
7.4.160.0090.01016.40
7.4.150.0110.00717.40
7.4.140.0100.01017.86
7.4.130.0170.00716.44
7.4.120.0070.01216.43
7.4.110.0100.00716.44
7.4.100.0110.01116.46
7.4.90.0110.00716.33
7.4.80.0120.01119.39
7.4.70.0100.01316.41
7.4.60.0160.01016.50
7.4.50.0040.00916.39
7.4.40.0000.01616.46
7.4.30.0090.00916.52
7.4.10.0000.01616.45
7.4.00.0080.00915.76
7.3.330.0000.00513.20
7.3.320.0000.00513.23
7.3.310.0030.00316.30
7.3.300.0030.00316.33
7.3.290.0070.01016.36
7.3.280.0100.00716.37
7.3.270.0090.00917.40
7.3.260.0080.00916.44
7.3.250.0090.00816.39
7.3.240.0100.00716.39
7.3.230.0190.00016.45
7.3.210.0070.01016.25
7.3.200.0090.00916.40
7.3.190.0090.00616.65
7.3.180.0070.01116.37
7.3.170.0230.00016.70
7.3.160.0030.01316.51
7.3.130.0030.01416.32
7.3.120.0100.00616.29
7.3.110.0030.01316.36
7.3.100.0030.01216.58
7.3.90.0000.01316.38
7.3.80.0130.00016.47
7.3.70.0070.00716.41
7.3.60.0090.00016.48
7.3.50.0000.01116.39
7.3.40.0000.01116.41
7.3.30.0070.01116.42
7.3.20.0070.00718.31
7.3.10.0060.00618.15
7.3.00.0100.00618.36
7.2.330.0100.00716.75
7.2.320.0100.01316.73
7.2.310.0130.00416.41
7.2.300.0040.01316.74
7.2.290.0090.01316.74
7.2.260.0160.00316.71
7.2.250.0150.00316.53
7.2.240.0130.00316.80
7.2.230.0070.00716.69
7.2.220.0040.01116.44
7.2.210.0060.01016.64
7.2.200.0090.00616.62
7.2.190.0140.00316.43
7.2.180.0040.00816.66
7.2.170.0150.00016.56
7.2.160.0110.00016.57
7.2.150.0060.00918.54
7.2.140.0060.00918.39
7.2.130.0090.00318.41
7.2.120.0060.00918.39
7.2.110.0100.00718.54
7.2.100.0040.00918.40
7.2.90.0070.00318.36
7.2.80.0030.01318.20
7.2.70.0030.01018.44
7.2.60.0060.00917.73
7.2.50.0060.00918.45
7.2.40.0070.01118.44
7.2.30.0070.00718.53
7.2.20.0030.01218.49
7.2.10.0080.00318.42
7.2.00.0090.00318.29
7.1.330.0030.01017.36
7.1.320.0040.00417.51
7.1.310.0090.00317.71
7.1.300.0030.01017.43
7.1.290.0030.01417.27
7.1.280.0080.00417.30
7.1.270.0030.00717.35
7.1.260.0100.00717.41
7.1.250.0060.00917.50
7.1.240.0070.00717.33
7.1.230.0030.00917.42
7.1.220.0110.00017.26
7.1.210.0100.00717.31
7.1.200.0080.00516.57
7.1.190.0100.00317.38
7.1.180.0060.00917.44
7.1.170.0100.00617.29
7.1.160.0060.00317.37
7.1.150.0040.01117.31
7.1.140.0070.01017.57
7.1.130.0080.00417.52
7.1.120.0090.00317.23
7.1.110.0040.01117.34
7.1.100.0000.01117.21
7.1.90.0040.01117.81
7.1.80.0040.01017.80
7.1.70.0030.01117.12
7.1.60.0090.01026.29
7.1.50.0100.01126.02
7.1.40.0130.00725.94
7.1.30.0110.00825.94
7.1.20.0090.01125.96
7.1.10.0060.00716.90
7.1.00.0040.01016.96
7.0.330.0080.01116.82
7.0.320.0030.01016.96
7.0.310.0000.00916.87
7.0.300.0040.00417.04
7.0.290.0060.00317.05
7.0.280.0040.00817.00
7.0.270.0040.01116.97
7.0.260.0070.00716.95
7.0.250.0060.00917.12
7.0.240.0000.01417.05
7.0.230.0120.00617.42
7.0.220.0110.00617.37
7.0.210.0050.00716.87
7.0.200.0020.01117.02
7.0.190.0100.00517.00
7.0.180.0100.00316.64
7.0.170.0070.00516.76
7.0.160.0040.01016.71
7.0.150.0030.01016.72
7.0.140.0070.00716.66
7.0.130.0080.00616.73
7.0.120.0050.00816.77
7.0.110.0030.01016.71
7.0.100.0060.01116.74
7.0.90.0060.01116.64
7.0.80.0020.01216.60
7.0.70.0050.00716.73
7.0.60.0070.00716.57
7.0.50.0030.01216.65
7.0.40.0090.00715.65
7.0.30.0030.00915.71
7.0.20.0030.01015.83
7.0.10.0050.00815.63
7.0.00.0050.01015.75
5.6.400.0090.00316.03
5.6.390.0040.01516.28
5.6.380.0000.01515.98
5.6.370.0090.00615.75
5.6.360.0070.00716.29
5.6.350.0030.01316.11
5.6.340.0100.00715.97
5.6.330.0060.00915.64
5.6.320.0000.01616.03
5.6.310.0110.00416.19
5.6.300.0070.00716.31
5.6.290.0090.00615.64
5.6.280.0090.00916.03
5.6.270.0110.00415.95
5.6.260.0110.00416.23
5.6.250.0030.01015.81
5.6.240.0070.01016.08
5.6.230.0040.01116.04
5.6.220.0000.01616.14
5.6.210.0030.01215.84
5.6.200.0060.00916.00
5.6.190.0090.00615.84
5.6.180.0050.00516.14
5.6.170.0040.00815.87
5.6.160.0080.00615.85
5.6.150.0140.00016.16
5.6.140.0060.00616.23
5.6.130.0080.00415.79
5.6.120.0030.00615.91
5.6.110.0060.01115.87
5.6.100.0060.00916.07
5.6.90.0120.00316.18
5.6.80.0060.00615.96
5.6.70.0080.00315.99
5.6.60.0070.00715.76
5.6.50.0040.00815.69
5.6.40.0000.00915.99
5.6.30.0080.00615.97
5.6.20.0040.01416.22
5.6.10.0070.01015.80
5.6.00.0110.00415.96

preferences:
46.59 ms | 401 KiB | 5 Q