3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RecursionImplementation { public static function recursionInitiator($array, $keylist) { self::$keys = explode(",", $keylist); if(count(self::$keys) == 0) return $array; $array = self::recursion($array); return $array; } private static function recursion($array) { $all_keys = array_keys($array); $intersection = array_intersect($all_keys, self::$keys); $difference = array_diff($all_keys, self::$keys); $number_of_intersecting_keys = count($intersection); $number_of_non_intersecting_keys = count($array) - $number_of_intersecting_keys; if($number_of_intersecting_keys + $number_of_non_intersecting_keys == 0) return; if($number_of_intersecting_keys >= 1) { foreach($intersection as $key) { unset($array[$key]); $array[$key] = self::$asterisk; } } if($number_of_non_intersecting_keys >= 1) { foreach($difference as $key) { if(is_array($array[$key])) { $value = self::recursion($array[$key]); unset($array[$key]); $array[$key] = $value; } } } return $array; } private static $keys; private static $asterisk = "**"; } $information = array("login" => "someUsername", "password" => "somePassword", "card_pin"=>"card_1234", "pin"=>"pin_356", "iin" => "iin_123", "shipping" => array("value" => array("telephone" => array("inner_value" => "telephone_998"))), "cardnumber" => "card_number_876", "customer_id" => "customer_654", "telephone" => "someOtherTelephoneNumber555"); $list = "telephone,login"; print_r($information); echo "\n\n"; $final_array = RecursionImplementation::recursionInitiator($information, $list); print_r($final_array);

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.70.0120.00318.43
8.3.60.0110.00716.88
8.3.50.0090.00922.11
8.3.40.0120.00318.63
8.3.30.0070.00718.81
8.3.20.0080.00020.16
8.3.10.0080.00023.45
8.3.00.0040.00419.38
8.2.190.0150.00316.75
8.2.180.0150.00616.63
8.2.170.0140.00422.96
8.2.160.0140.00020.52
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0070.00021.03
8.2.110.0070.00320.47
8.2.100.0120.00017.93
8.2.90.0000.00819.15
8.2.80.0040.00417.97
8.2.70.0050.00317.61
8.2.60.0000.00817.93
8.2.50.0030.00618.07
8.2.40.0080.00019.38
8.2.30.0050.00320.55
8.2.20.0040.00417.75
8.2.10.0020.00518.14
8.2.00.0030.00618.18
8.1.280.0080.01125.92
8.1.270.0030.00722.02
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0030.00623.83
8.1.230.0040.00817.66
8.1.220.0040.00417.80
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0100.00716.98
8.1.180.0040.00418.10
8.1.170.0030.00518.71
8.1.160.0050.00321.96
8.1.150.0000.00718.91
8.1.140.0000.00819.63
8.1.130.0000.00717.75
8.1.120.0050.00317.37
8.1.110.0030.00517.39
8.1.100.0000.00817.43
8.1.90.0040.00417.48
8.1.80.0070.00017.46
8.1.70.0070.00017.28
8.1.60.0040.00417.59
8.1.50.0000.00817.47
8.1.40.0030.00617.49
8.1.30.0030.00617.66
8.1.20.0000.00817.53
8.1.10.0040.00417.46
8.1.00.0040.00417.52
8.0.300.0040.00418.77
8.0.290.0050.00216.63
8.0.280.0030.00318.37
8.0.270.0000.00717.27
8.0.260.0000.00617.27
8.0.250.0040.00416.93
8.0.240.0100.00016.98
8.0.230.0030.00317.00
8.0.220.0040.00416.86
8.0.210.0000.00816.77
8.0.200.0000.00616.98
8.0.190.0080.00016.85
8.0.180.0050.00316.77
8.0.170.0030.00616.94
8.0.160.0000.00816.94
8.0.150.0000.00716.89
8.0.140.0040.00416.84
8.0.130.0040.00413.36
8.0.120.0060.00316.80
8.0.110.0080.00016.91
8.0.100.0040.00416.71
8.0.90.0030.00516.68
8.0.80.0070.00816.78
8.0.70.0040.00416.75
8.0.60.0000.00816.92
8.0.50.0030.00516.93
8.0.30.0090.00916.93
8.0.20.0090.01317.40
8.0.10.0070.00017.01
8.0.00.0080.00916.85
7.4.330.0020.00216.79
7.4.320.0030.00516.58
7.4.300.0030.00316.60
7.4.290.0020.00516.53
7.4.280.0000.00716.46
7.4.270.0070.00016.60
7.4.260.0000.00716.39
7.4.250.0040.00416.57
7.4.240.0000.00916.52
7.4.230.0000.00716.61
7.4.220.0100.00716.45
7.4.210.0120.00316.61
7.4.200.0070.00016.41
7.4.160.0110.00416.56
7.4.150.0090.00917.40
7.4.140.0130.00917.86
7.4.130.0090.01216.47
7.4.120.0090.01016.57
7.4.110.0070.01016.58
7.4.100.0090.00916.65
7.4.90.0150.00316.48
7.4.80.0130.00719.39
7.4.70.0100.00716.45
7.4.60.0060.01016.53
7.4.50.0070.01016.23
7.4.40.0030.01416.47
7.4.30.0130.00716.52
7.4.00.0060.00614.75
7.3.330.0030.00313.39
7.3.320.0000.00513.36
7.3.310.0040.00416.37
7.3.300.0030.00316.26
7.3.290.0090.00916.31
7.3.280.0120.01316.36
7.3.270.0060.01017.40
7.3.260.0110.00616.36
7.3.250.0110.01216.44
7.3.240.0110.01016.47
7.3.230.0080.00916.43
7.3.210.0100.00716.53
7.3.200.0070.01016.54
7.3.190.0090.00916.36
7.3.180.0150.00016.52
7.3.170.0150.00316.56
7.3.160.0090.00616.63
7.3.10.0000.01316.59
7.3.00.0000.01016.63
7.2.330.0070.01016.79
7.2.320.0160.00616.79
7.2.310.0120.00616.71
7.2.300.0120.00916.90
7.2.290.0140.00716.80
7.2.130.0070.01016.93
7.2.120.0000.01516.78
7.2.110.0100.00716.64
7.2.100.0030.00616.77
7.2.90.0130.00317.07
7.2.80.0060.00716.93
7.2.70.0090.00616.95
7.2.60.0100.00716.94
7.2.50.0130.00216.76
7.2.40.0070.00317.15
7.2.30.0040.01216.64
7.2.20.0030.01016.93
7.2.10.0070.00316.72
7.2.00.0100.00316.93
7.1.250.0000.01415.77
7.1.200.0040.00415.60
7.1.100.0030.00818.14
7.1.70.0040.00716.91
7.1.60.0160.00619.48
7.1.50.0060.00617.05
7.1.00.0100.07022.50
7.0.200.0190.00614.97
7.0.60.0030.06319.91
7.0.50.0000.05017.85
7.0.40.0070.05020.23
7.0.30.0200.07720.30
7.0.20.0270.08720.30
7.0.10.0030.09320.24
7.0.00.0070.05320.29
5.6.280.0000.07021.02
5.6.210.0000.04320.71
5.6.200.0030.05018.14
5.6.190.0070.09020.77
5.6.180.0270.04720.57
5.6.170.0400.05320.71
5.6.160.0100.07720.46
5.6.150.0000.06318.15
5.6.140.0030.04018.16
5.6.130.0170.07318.16
5.6.120.0100.03720.88
5.6.110.0070.08721.06
5.6.100.0170.07320.90
5.6.90.0030.06021.14
5.6.80.0100.05320.55
5.5.350.3370.04720.34
5.5.340.0030.04317.95
5.5.330.0130.07720.47
5.5.320.0370.04720.30
5.5.310.0170.07320.28
5.5.300.0100.07018.07
5.5.290.0000.04317.98
5.5.280.0000.04320.66
5.5.270.0030.06720.69
5.5.260.0030.08720.88
5.5.250.0030.07720.78
5.5.240.0200.07320.27

preferences:
52.29 ms | 401 KiB | 5 Q