3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string_original = " Ivq6T2IoWbLNCoru7RTv kcEDwTVDhkqRAePOOQsM c6pcDsaq1waWzuzNHAYl pqFRFt1XwSX6JBLslwDs VWygeUir8kWMOpU5RArI WZ1UCYybMhpetyaCCkiM 8OVqENVpWmCZvDyvq8dG PPxPs48xPuiaLGdKhjEl 2i5y2URwQlRS1pbrKDS5 euT3KHvPrhM5wnOyTpJv "; var_dump($string_original); $string = $string_original; $pattern = '%' # Select a digit and 5 letters after .'(\d)(\w{5})' .'%'; $string = preg_replace_callback( $pattern, function($matches){ # Add to one to digit and then lowercase 5 letters after. $matches[1] = $matches[1] + 1; $matches[2] = strtolower($matches[2]); return $matches[1].$matches[2]; }, $string); var_dump($string); $string = $string_original; $pattern = '%' # Any digit and after 5 alpha-numeric characters. .'(\d)(?<=\w{5})' .'%'; # Replace all integers to symbols $string = preg_replace_callback( $pattern, function($matches){ if($matches[1] >= 5){ return '_'; }else{ return '@'; } }, $string, # Limit only 2 replacements 2); var_dump($string); # Array Replacement $arr = [ 'IUjd5x13NF1OyQn9Afjy', 'S1BG0EhuWxr5icrgD1St', 'oLKV7cI6Qx5503K0eJ6U', 'V36IgE0TE6Qq6beBnJkC', 'jcMIKR9wk9u8kdN6UyPR', 'N8CNqZDQPJwLH87rnmKq', 'yeSAo75DcWQqQM9FynIu', 'QoRWAnP2G1LGkRoBbiud', 'tiVkR9UkIiB6ChI6l6Se', '9BWLYV7msRz7WsSADx7u' ]; $pattern = '%' # Any Digit after 10 characters .'(\d)(?<=\w{10})' .'%'; # Replace integers from <5 to _ and >5 to @ # Note the limit here works per line in the array. # And the count can be gathered via another variable declaration on the function. $arr = preg_replace_callback( $pattern, function($matches){ if($matches[1] >= 5){ return '_'; }else{ return '@'; } }, $arr, 1, $count); var_dump($arr); var_dump($count);

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.0040.01116.75
8.3.60.0060.01018.56
8.3.50.0130.00416.66
8.3.40.0080.00819.15
8.3.30.0090.00618.96
8.3.20.0080.00020.73
8.3.10.0080.00020.22
8.3.00.0030.00621.89
8.2.180.0070.00725.92
8.2.170.0040.01119.20
8.2.160.0110.00322.96
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0050.00326.16
8.2.120.0050.00319.91
8.2.110.0030.00622.44
8.2.100.0080.00418.10
8.2.90.0030.00518.32
8.2.80.0100.00019.28
8.2.70.0030.00618.05
8.2.60.0040.00418.34
8.2.50.0030.00518.10
8.2.40.0030.00619.47
8.2.30.0030.00619.30
8.2.20.0000.00818.15
8.2.10.0040.00419.11
8.2.00.0000.00719.70
8.1.280.0120.00325.92
8.1.270.0000.00920.65
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.96
8.1.230.0060.00621.01
8.1.220.0030.00517.91
8.1.210.0000.00818.89
8.1.200.0030.01017.60
8.1.190.0080.00017.60
8.1.180.0050.00318.10
8.1.170.0040.00418.91
8.1.160.0040.00419.01
8.1.150.0040.00419.02
8.1.140.0040.00418.95
8.1.130.0070.00020.20
8.1.120.0040.00417.63
8.1.110.0070.00017.62
8.1.100.0000.00717.58
8.1.90.0000.00817.59
8.1.80.0000.00817.55
8.1.70.0030.00517.68
8.1.60.0030.00517.67
8.1.50.0040.00417.62
8.1.40.0050.00317.69
8.1.30.0040.00417.84
8.1.20.0000.00917.77
8.1.10.0030.00617.81
8.1.00.0040.00417.60
8.0.300.0070.00020.22
8.0.290.0080.00016.75
8.0.280.0000.00718.49
8.0.270.0040.00416.96
8.0.260.0050.00318.38
8.0.250.0070.00017.18
8.0.240.0000.01017.20
8.0.230.0040.00417.18
8.0.220.0060.00317.16
8.0.210.0000.00817.05
8.0.200.0000.00717.07
8.0.190.0000.00717.14
8.0.180.0040.00417.23
8.0.170.0050.00317.18
8.0.160.0040.00417.19
8.0.150.0030.00617.06
8.0.140.0000.00717.05
8.0.130.0030.00413.59
8.0.120.0040.00417.05
8.0.110.0050.00216.95
8.0.100.0040.00417.22
8.0.90.0000.00817.14
8.0.80.0150.00017.12
8.0.70.0000.00717.00
8.0.60.0000.00717.07
8.0.50.0040.00417.07
8.0.30.0080.00917.39
8.0.20.0170.00517.08
8.0.10.0040.00417.27
8.0.00.0090.00917.03
7.4.330.0000.00515.55
7.4.320.0030.00316.82
7.4.300.0040.00416.74
7.4.290.0050.00316.85
7.4.280.0030.00616.77
7.4.270.0030.00316.88
7.4.260.0030.00316.72
7.4.250.0080.00016.63
7.4.240.0000.00716.80
7.4.230.0000.00716.54
7.4.220.0040.00416.72
7.4.210.0100.00916.79
7.4.200.0030.00316.72
7.4.160.0100.01016.81
7.4.140.0170.00317.86
7.4.130.0110.01216.86
7.4.120.0150.00316.83
7.4.110.0060.01216.66
7.4.100.0100.00716.57
7.4.90.0080.00816.79
7.4.80.0110.01119.39
7.4.70.0120.00816.70
7.4.60.0060.01216.71
7.4.50.0110.00216.57
7.4.40.0140.01016.61
7.4.00.0090.00715.27
7.3.330.0000.00513.47
7.3.320.0000.00613.30
7.3.310.0000.00716.51
7.3.300.0030.00316.40
7.3.290.0030.00316.34
7.3.280.0070.00816.44
7.3.260.0080.01216.59
7.3.240.0100.00816.63
7.3.230.0060.01316.84
7.3.210.0030.01316.90
7.3.200.0130.00616.80
7.3.190.0060.00916.54
7.3.180.0090.00916.53
7.3.170.0080.01216.50
7.3.160.0140.00816.55
7.3.120.0060.01214.56
7.3.110.0070.01015.15
7.3.100.0030.01515.23
7.3.90.0090.00914.90
7.3.80.0090.00615.32
7.3.70.0030.00714.72
7.3.60.0040.01115.01
7.3.50.0090.00914.88
7.3.40.0090.00514.84
7.3.30.0110.00815.00
7.3.20.0050.01016.94
7.3.10.0100.00816.90
7.3.00.0050.00816.76
7.2.330.0100.00816.79
7.2.320.0040.01316.90
7.2.310.0120.00616.75
7.2.300.0100.01316.68
7.2.290.0170.00016.77
7.2.250.0030.01615.30
7.2.240.0070.01415.02
7.2.230.0090.00615.13
7.2.220.0130.00715.18
7.2.210.0130.00315.34
7.2.200.0000.01615.23
7.2.190.0100.00014.91
7.2.180.0080.01015.20
7.2.170.0080.00815.13
7.2.160.0060.00615.09
7.2.150.0160.00317.14
7.2.140.0110.01217.06
7.2.130.0170.00617.06
7.2.120.0150.00616.74
7.2.110.0040.00817.11
7.2.100.0000.01517.11
7.2.90.0190.00317.20
7.2.80.0060.01717.09
7.2.70.0100.00317.01
7.2.60.0140.00017.22
7.2.50.0090.00917.07
7.2.40.0110.00617.16
7.2.30.0160.00617.18
7.2.20.0140.00717.16
7.2.10.0170.00717.00
7.2.00.0110.00417.14
7.1.330.0100.00316.09
7.1.320.0060.00315.89
7.1.310.0040.00715.82
7.1.300.0080.00416.11
7.1.290.0070.01015.68
7.1.280.0060.01115.92
7.1.270.0040.00915.91
7.1.260.0060.00615.99
7.1.250.0110.01015.95

preferences:
55.33 ms | 401 KiB | 5 Q