3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sanitize_sentence($string) { $pats = array( '/([.!?]\s{2}),/', # Abc. ,Def '/\.+(,)/', # ......, '/(!|\?)\1+/', # abc!!!!!!!!, abc????????? '/\s+(,)/', # abc , def '/([a-zA-Z])\1\1/'); # greeeeeeen $fixed = preg_replace($pats,'$1',$string); $fixed = preg_replace('/,(?!\s)/',', ',$fixed); $fixed = preg_replace( '/([!?,.])(\S)/', '$1 $2', $fixed); $fixed = preg_replace( '/[^a-zA-Z0-9!?.]$/', '.', $fixed); return $fixed; } echo sanitize_sentence('hello!!!!!!there should be a space after the exclamation mark.right???????yes.right,');

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.0070.01416.75
8.3.60.0100.00718.40
8.3.50.0070.01221.33
8.3.40.0150.00018.96
8.3.30.0090.00618.88
8.3.20.0000.00818.90
8.3.10.0040.00420.96
8.3.00.0040.00423.64
8.2.180.0070.00716.88
8.2.170.0040.01122.96
8.2.160.0100.00720.35
8.2.150.0090.00924.18
8.2.140.0030.00524.66
8.2.130.0050.00326.16
8.2.120.0040.00419.79
8.2.110.0060.01222.20
8.2.100.0060.00617.91
8.2.90.0030.00718.03
8.2.80.0060.00317.97
8.2.70.0000.00817.75
8.2.60.0040.00417.93
8.2.50.0000.00918.07
8.2.40.0000.00818.16
8.2.30.0030.00619.34
8.2.20.0040.00417.69
8.2.10.0000.00817.81
8.2.00.0000.00817.75
8.1.280.0130.00625.92
8.1.270.0000.00823.99
8.1.260.0000.00926.35
8.1.250.0040.00428.09
8.1.240.0060.00320.83
8.1.230.0060.00620.84
8.1.220.0060.00317.80
8.1.210.0090.00018.91
8.1.200.0000.00917.48
8.1.190.0050.00317.40
8.1.180.0050.00318.10
8.1.170.0050.00318.68
8.1.160.0050.00318.77
8.1.150.0080.00018.79
8.1.140.0030.00517.54
8.1.130.0000.00717.81
8.1.120.0000.00717.44
8.1.110.0030.00617.55
8.1.100.0000.00717.43
8.1.90.0040.00417.45
8.1.80.0050.00317.56
8.1.70.0000.00717.54
8.1.60.0060.00317.79
8.1.50.0040.00417.62
8.1.40.0060.00317.69
8.1.30.0080.00017.74
8.1.20.0000.00817.70
8.1.10.0000.00817.57
8.1.00.0050.00517.59
8.0.300.0060.00319.98
8.0.290.0040.00417.05
8.0.280.0030.00318.39
8.0.270.0080.00017.21
8.0.260.0030.00317.02
8.0.250.0000.00817.05
8.0.240.0060.00317.12
8.0.230.0000.00717.06
8.0.220.0000.00717.00
8.0.210.0000.00817.00
8.0.200.0000.00716.93
8.0.190.0080.00017.04
8.0.180.0000.00816.91
8.0.170.0000.00916.91
8.0.160.0000.00716.95
8.0.150.0030.00516.85
8.0.140.0000.00716.98
8.0.130.0030.00313.43
8.0.120.0030.00616.84
8.0.110.0000.00816.95
8.0.100.0000.00816.90
8.0.90.0030.00616.79
8.0.80.0150.00616.87
8.0.70.0040.00417.02
8.0.60.0050.00316.81
8.0.50.0000.00816.97
8.0.30.0100.01317.28
8.0.20.0050.01317.44
8.0.10.0000.00817.00
8.0.00.0050.01216.62
7.4.330.0000.00514.81
7.4.320.0000.00816.81
7.4.300.0030.00316.82
7.4.290.0000.00716.62
7.4.280.0000.00716.63
7.4.270.0040.00416.71
7.4.260.0000.00713.60
7.4.250.0050.00516.64
7.4.240.0070.00016.87
7.4.230.0030.00316.93
7.4.220.0100.00916.72
7.4.210.0070.01016.83
7.4.200.0000.00816.78
7.4.190.0040.00416.96
7.4.160.0080.00816.65
7.4.150.0120.00617.40
7.4.140.0030.01417.86
7.4.130.0050.01316.78
7.4.120.0090.00916.76
7.4.110.0150.00416.60
7.4.100.0180.00616.88
7.4.90.0090.01016.48
7.4.80.0100.01319.39
7.4.70.0130.00616.55
7.4.60.0060.01016.72
7.4.50.0000.00916.77
7.4.40.0030.00922.52
7.4.30.0090.00916.70
7.4.00.0080.00615.02
7.3.330.0000.00513.41
7.3.320.0000.00513.15
7.3.310.0000.00716.43
7.3.300.0030.00316.27
7.3.290.0100.01016.37
7.3.280.0090.00816.39
7.3.270.0130.00317.40
7.3.260.0130.00518.24
7.3.250.0090.00916.56
7.3.240.0110.01116.69
7.3.230.0110.00716.82
7.3.210.0090.00916.57
7.3.200.0130.00319.39
7.3.190.0130.00316.70
7.3.180.0060.00916.67
7.3.170.0070.01016.37
7.3.160.0080.00816.47
7.3.120.0090.00715.03
7.3.110.0040.01115.10
7.3.100.0040.00714.82
7.3.90.0040.01114.99
7.3.80.0070.01014.63
7.3.70.0030.00914.94
7.3.60.0030.00714.56
7.3.50.0030.01315.05
7.3.40.0070.01015.05
7.3.30.0040.01114.96
7.3.20.0110.00416.81
7.3.10.0060.00616.45
7.3.00.0060.00916.89
7.2.330.0000.01816.77
7.2.320.0100.01016.79
7.2.310.0110.00616.75
7.2.300.0110.00716.80
7.2.290.0080.01116.77
7.2.250.0100.00715.32
7.2.240.0060.01214.81
7.2.230.0110.00315.05
7.2.220.0030.01115.36
7.2.210.0170.00015.40
7.2.200.0030.00915.33
7.2.190.0000.01015.14
7.2.180.0000.01315.22
7.2.170.0000.01315.17
7.1.330.0070.01115.53
7.1.320.0030.01315.98
7.1.310.0000.01515.88
7.1.300.0080.00416.02
7.1.290.0090.00315.87
7.1.280.0030.01315.90
7.1.270.0000.01315.80
7.1.260.0080.00015.89
7.1.200.0060.00615.94
7.1.70.0000.01117.49
7.1.60.0120.01219.40
7.1.50.0260.01334.66
7.1.00.0100.04022.43
7.0.200.0030.00316.68
7.0.140.0030.07022.18
7.0.70.0270.03019.91
7.0.60.0100.07021.69
7.0.50.0100.03320.21
7.0.40.0070.05320.18
7.0.30.0070.08720.05
7.0.20.0100.08320.04
7.0.10.0100.06020.02
7.0.00.0070.08320.02
5.6.280.0100.07321.11
5.6.220.0100.08320.65
5.6.210.0070.04720.46
5.6.200.0030.08021.11
5.6.190.0100.05721.05
5.6.180.0070.07721.11
5.6.170.0170.04721.05
5.6.160.0130.07721.08
5.6.150.0100.08021.11
5.6.140.0000.04021.02
5.6.130.0070.03321.05
5.6.120.0230.05021.05
5.6.110.0030.07721.16
5.6.100.0000.04021.02
5.6.90.0030.07021.04
5.6.80.0070.03320.33
5.6.70.0100.05020.43
5.6.60.0030.03720.33
5.6.50.0030.04020.50
5.6.40.0070.04320.30
5.6.30.0070.04720.45
5.6.20.0070.04020.43
5.6.10.0100.07720.44
5.6.00.0200.07020.39
5.5.360.0030.04320.39
5.5.350.0030.05020.45
5.5.340.0070.04720.76
5.5.330.0100.05020.92
5.5.320.0100.07020.77
5.5.310.0100.07720.93
5.5.300.0100.03720.91
5.5.290.0070.04020.87
5.5.280.0070.04320.94
5.5.270.0000.04020.76
5.5.260.0100.07320.72
5.5.250.0030.06720.70
5.5.240.0070.03720.16
5.5.230.0030.05020.28
5.5.220.0070.03720.25
5.5.210.0000.04320.19
5.5.200.0000.05320.19
5.5.190.0070.03720.23
5.5.180.0100.04020.11
5.5.160.0030.03320.22
5.5.150.0030.03320.24
5.5.140.0030.03320.09
5.5.130.0030.07720.15
5.5.120.0030.04020.13
5.5.110.0000.04320.08
5.5.100.0070.03720.08
5.5.90.0070.03019.95
5.5.80.0000.04720.16
5.5.70.0000.03720.13
5.5.60.0170.02720.16
5.5.50.0170.03320.04
5.5.40.0100.04720.10
5.5.30.0070.07720.06
5.5.20.0130.04320.09
5.5.10.0100.07720.06
5.5.00.0000.05320.03
5.4.450.0000.05319.18
5.4.440.0030.04019.27
5.4.430.0070.07719.26
5.4.420.0070.04719.32
5.4.410.0070.03019.23
5.4.400.0000.04019.05
5.4.390.0030.04019.16
5.4.380.0030.06719.04
5.4.370.0030.03719.05
5.4.360.0070.04319.09
5.4.350.0070.09019.12
5.4.340.0070.05719.03
5.4.320.0170.02319.13
5.4.310.0070.06319.14
5.4.300.0030.03719.02
5.4.290.0100.03019.20
5.4.280.0030.03719.00
5.4.270.0000.03319.03
5.4.260.0100.03019.09
5.4.250.0030.03719.12
5.4.240.0070.06319.18
5.4.230.0000.04019.17
5.4.220.0070.04019.08
5.4.210.0030.03718.94
5.4.200.0170.06019.22
5.4.190.0070.07319.11
5.4.180.0100.07719.17
5.4.170.0170.06719.04
5.4.160.0100.05019.10
5.4.150.0000.04319.10
5.4.140.0030.08016.51
5.4.130.0030.06316.47
5.4.120.0030.06016.50
5.4.110.0130.07016.42
5.4.100.0070.03716.56
5.4.90.0200.03016.41
5.4.80.0100.07016.51
5.4.70.0000.05016.55
5.4.60.0070.04316.48
5.4.50.0170.06016.39
5.4.40.0070.07316.39
5.4.30.0100.06016.48
5.4.20.0100.07016.39
5.4.10.0100.06316.50
5.4.00.0070.06315.87
5.3.290.0000.05314.80
5.3.280.0030.03314.64
5.3.270.0100.06014.55
5.3.260.0070.05014.65
5.3.250.0130.06714.70
5.3.240.0100.06014.69
5.3.230.0070.07714.59
5.3.220.0130.06314.57
5.3.210.0070.08014.50
5.3.200.0070.05314.58
5.3.190.0030.08314.58
5.3.180.0030.06314.62
5.3.170.0070.07714.59
5.3.160.0100.05314.59
5.3.150.0070.06714.60
5.3.140.0100.06314.69
5.3.130.0070.08314.48
5.3.120.0100.07314.65
5.3.110.0130.07314.55
5.3.100.0030.06014.01
5.3.90.0100.07013.97
5.3.80.0100.06014.03
5.3.70.0100.07714.13
5.3.60.0070.07313.90
5.3.50.0070.04013.83
5.3.40.0070.07313.96
5.3.30.0100.07013.82
5.3.20.0070.07313.81
5.3.10.0030.07713.62
5.3.00.0070.07313.70
5.2.170.0100.05013.62
5.2.160.0070.04713.62
5.2.150.0170.05313.62
5.2.140.0030.07013.62
5.2.130.0000.04013.62
5.2.120.0030.04313.62
5.2.110.0100.04313.62
5.2.100.0030.06313.62
5.2.90.0100.05713.62
5.2.80.0030.04313.62
5.2.70.0000.04013.62
5.2.60.0030.04313.62
5.2.50.0070.05713.62
5.2.40.0070.04313.62
5.2.30.0070.06313.62
5.2.20.0070.05713.62
5.2.10.0100.04713.62
5.2.00.0030.06013.62
5.1.60.0030.03713.62
5.1.50.0070.05313.62
5.1.40.0000.04713.62
5.1.30.0030.05313.62
5.1.20.0030.05713.62
5.1.10.0030.03713.62
5.1.00.0030.03313.62
5.0.50.0100.01713.62
5.0.40.0030.02013.62
5.0.30.0030.03013.62
5.0.20.0030.04313.62
5.0.10.0030.03713.62
5.0.00.0130.06013.62
4.4.90.0070.02713.62
4.4.80.0030.03313.62
4.4.70.0070.02313.62
4.4.60.0070.02313.62
4.4.50.0070.03013.62
4.4.40.0030.05713.62
4.4.30.0070.02013.62
4.4.20.0070.03313.62
4.4.10.0000.01713.62
4.4.00.0000.02713.62
4.3.110.0030.01313.62
4.3.100.0000.02313.62
4.3.90.0000.03713.62
4.3.80.0070.05013.62
4.3.70.0030.02713.62
4.3.60.0070.02013.62
4.3.50.0000.04013.62
4.3.40.0000.04013.62
4.3.30.0030.03713.62
4.3.20.0000.01713.62
4.3.10.0000.01713.62
4.3.00.0030.03713.62

preferences:
43.97 ms | 401 KiB | 5 Q