3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RecursionImplementation { public static function recursionInitiator($array, $keylist) { self::$keys = explode(",", $keylist); if(is_null(self::keys) || 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.60.0070.01116.63
8.3.50.0120.00318.18
8.3.40.0090.00618.84
8.3.30.0140.00718.66
8.3.20.0030.00620.31
8.3.10.0000.00823.53
8.3.00.0000.00819.51
8.2.180.0070.01116.50
8.2.170.0090.00622.96
8.2.160.0110.00420.53
8.2.150.0060.00324.18
8.2.140.0000.00824.66
8.2.130.0030.00617.38
8.2.120.0090.00626.35
8.2.110.0040.00420.52
8.2.100.0040.00718.04
8.2.90.0040.00419.27
8.2.80.0030.00617.97
8.2.70.0040.00417.50
8.2.60.0040.00417.93
8.2.50.0050.00318.07
8.2.40.0040.00419.47
8.2.30.0070.00020.69
8.2.20.0060.00317.62
8.2.10.0000.00718.19
8.2.00.0000.00718.10
8.1.280.0070.01125.92
8.1.270.0060.00322.21
8.1.260.0080.00028.09
8.1.250.0000.00828.09
8.1.240.0030.00623.98
8.1.230.0040.00817.66
8.1.220.0040.00417.74
8.1.210.0030.00518.77
8.1.200.0060.00317.25
8.1.190.0030.00817.13
8.1.180.0040.00418.10
8.1.170.0000.00918.84
8.1.160.0080.00022.00
8.1.150.0040.00418.82
8.1.140.0000.00819.49
8.1.130.0000.00717.62
8.1.120.0040.00417.53
8.1.110.0000.00717.53
8.1.100.0000.00817.51
8.1.90.0030.00317.46
8.1.80.0040.00417.33
8.1.70.0030.00317.39
8.1.60.0050.00317.61
8.1.50.0040.00417.54
8.1.40.0040.00417.40
8.1.30.0000.00817.63
8.1.20.0080.00017.67
8.1.10.0000.00817.45
8.1.00.0000.00817.45
8.0.300.0000.00818.77
8.0.290.0000.00716.75
8.0.280.0000.00818.44
8.0.270.0000.00717.31
8.0.260.0030.00317.21
8.0.250.0000.00716.92
8.0.240.0040.00416.99
8.0.230.0070.00016.91
8.0.220.0050.00216.86
8.0.210.0000.00717.02
8.0.200.0070.00016.99
8.0.190.0000.00817.00
8.0.180.0030.00517.01
8.0.170.0030.00616.96
8.0.160.0070.00016.88
8.0.150.0000.00716.90
8.0.140.0040.00416.84
8.0.130.0000.00613.31
8.0.120.0040.00416.82
8.0.110.0030.00517.01
8.0.100.0040.00416.97
8.0.90.0000.00716.87
8.0.80.0040.01216.91
8.0.70.0040.00416.81
8.0.60.0040.00416.99
8.0.50.0070.00016.85
8.0.30.0140.00617.13
8.0.20.0120.00717.40
8.0.10.0040.00416.95
8.0.00.0080.01116.70
7.4.330.0020.00216.69
7.4.320.0070.00016.43
7.4.300.0050.00216.59
7.4.290.0000.00816.48
7.4.280.0000.00816.40
7.4.270.0030.00316.58
7.4.260.0070.00016.63
7.4.250.0000.00716.48
7.4.240.0040.00416.56
7.4.230.0070.00016.62
7.4.220.0110.01116.68
7.4.210.0040.01116.57
7.4.200.0030.00316.51
7.4.160.0130.00316.52
7.4.150.0130.00617.40
7.4.140.0140.01017.86
7.4.130.0040.01316.53
7.4.120.0100.00616.58
7.4.110.0120.00816.67
7.4.100.0180.00416.65
7.4.90.0140.00316.34
7.4.80.0110.00619.39
7.4.70.0140.00416.63
7.4.60.0100.00616.63
7.4.50.0030.01016.51
7.4.40.0140.00316.59
7.4.30.0070.01016.70
7.4.00.0040.01214.84
7.3.330.0040.00413.16
7.3.320.0030.00313.25
7.3.310.0050.00216.38
7.3.300.0000.00716.40
7.3.290.0100.00616.38
7.3.280.0060.01116.37
7.3.270.0060.01217.40
7.3.260.0150.00316.43
7.3.250.0060.01216.42
7.3.240.0130.00416.42
7.3.230.0070.01316.39
7.3.210.0120.00616.46
7.3.200.0110.00816.41
7.3.190.0130.01016.43
7.3.180.0060.01216.61
7.3.170.0120.00916.50
7.3.160.0060.00916.46
7.3.10.0030.01016.68
7.3.00.0050.00516.54
7.2.330.0170.00016.50
7.2.320.0090.00916.84
7.2.310.0150.00016.48
7.2.300.0100.00716.47
7.2.290.0070.01416.83
7.2.130.0040.00716.73
7.2.120.0030.00616.74
7.2.110.0070.00716.60
7.2.100.0100.00316.74
7.2.90.0030.00816.82
7.2.80.0060.00616.63
7.2.70.0090.00316.65
7.2.60.0060.00816.99
7.2.50.0060.00916.84
7.2.40.0030.01216.81
7.2.30.0000.00916.92
7.2.20.0180.00416.95
7.2.10.0060.00316.83
7.2.00.0060.00618.31
7.1.250.0070.00315.70
7.1.240.0060.00615.39
7.1.230.0030.00715.68
7.1.220.0030.01015.71
7.1.210.0030.00715.64
7.1.200.0080.00615.64
7.1.190.0030.00915.75
7.1.180.0030.00715.68
7.1.170.0060.00915.52
7.1.160.0040.00715.84
7.1.150.0040.00715.67
7.1.140.0060.00615.66
7.1.130.0070.00715.78
7.1.120.0140.00015.83
7.1.110.0070.00715.57
7.1.100.0060.00817.01
7.1.90.0060.00615.75
7.1.80.0090.00615.70
7.1.70.0030.00816.44
7.1.60.0140.00917.56
7.1.50.0130.00825.17
7.1.40.0000.01115.70
7.1.30.0120.00315.74
7.1.20.0060.00615.36
7.1.10.0060.00915.68
7.1.00.0050.04218.95
7.0.330.0000.01015.31
7.0.320.0030.01015.28
7.0.310.0040.00715.21
7.0.300.0110.00315.32
7.0.290.0060.00615.13
7.0.280.0030.00715.39
7.0.270.0030.00615.38
7.0.260.0030.00615.27
7.0.250.0060.00615.05
7.0.240.0080.00415.16
7.0.230.0100.00615.10
7.0.220.0040.00415.10
7.0.210.0040.00715.31
7.0.200.0200.00814.90
7.0.190.0000.01115.20
7.0.180.0000.01015.12
7.0.170.0070.00715.33
7.0.160.0070.00415.57
7.0.150.0040.00415.38
7.0.140.0060.00615.27
7.0.130.0030.00915.30
7.0.120.0090.00615.34
7.0.110.0160.00315.21
7.0.100.0130.00315.44
7.0.90.0100.00715.48
7.0.80.0220.00315.29
7.0.70.0060.00315.01
7.0.60.0080.04017.62
7.0.50.0080.02316.62
7.0.40.0050.04416.85
7.0.30.0070.02916.78
7.0.20.0170.03516.61
7.0.10.0090.05016.74
7.0.00.0040.03216.71
5.6.380.0070.00314.13
5.6.370.0060.00914.37
5.6.360.0040.01114.02
5.6.350.0040.01414.54
5.6.340.0050.00714.06
5.6.330.0000.01113.96
5.6.320.0080.00814.16
5.6.310.0070.00714.16
5.6.300.0060.00614.37
5.6.290.0160.00014.53
5.6.280.0050.04217.65
5.6.270.0030.01014.06
5.6.260.0040.01214.18
5.6.250.0030.01214.39
5.6.240.0100.00014.34
5.6.230.0120.00314.16
5.6.220.0050.01014.26
5.6.210.0130.02317.52
5.6.200.0030.04816.31
5.6.190.0100.02617.40
5.6.180.0180.04017.41
5.6.170.0240.02317.51
5.6.160.0140.04317.37
5.6.150.0070.02516.37
5.6.140.0080.02016.36
5.6.130.0060.03616.41
5.6.120.0090.02217.62
5.6.110.0070.04417.70
5.6.100.0070.04617.64
5.6.90.0080.04017.62
5.6.80.0110.02817.37
5.6.70.0070.00714.40
5.6.60.0080.00414.35
5.6.50.0040.00914.42
5.6.40.0240.00013.78
5.6.30.0140.00314.04
5.6.20.0100.00714.43
5.6.10.0070.00713.86
5.6.00.0060.00814.11
5.5.380.0030.00611.00
5.5.370.0040.00711.22
5.5.360.0060.00610.98
5.5.350.2130.02115.81
5.5.340.0090.04014.63
5.5.330.0080.03015.84
5.5.320.0350.03815.76
5.5.310.0190.02315.78
5.5.300.0030.04114.61
5.5.290.0050.02314.42
5.5.280.0030.02916.03
5.5.270.0050.02016.03
5.5.260.0040.03416.06
5.5.250.0030.04815.96
5.5.240.0150.04115.61
5.5.230.0030.00310.88
5.5.220.0070.00310.90
5.5.210.0000.01011.07
5.5.200.0090.00410.66
5.5.190.0030.01611.04
5.5.180.0060.00311.16
5.5.170.0000.01311.20
5.5.160.0040.00710.75
5.5.150.0070.00410.99
5.5.140.0020.00911.13
5.5.130.0060.00610.67
5.5.120.0080.00410.63
5.5.110.0140.00011.09
5.5.100.0000.00910.77
5.5.90.0090.00310.88
5.5.80.0000.01110.89
5.5.70.0030.00910.92
5.5.60.0070.00310.79
5.5.50.0030.00710.75
5.5.40.0090.00210.82
5.5.30.0030.00810.93
5.5.20.0060.00411.02
5.5.10.0090.00010.55
5.5.00.0060.00610.91

preferences:
46.37 ms | 400 KiB | 5 Q