3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stripNonValidCharaters ($message) { $message = mb_convert_encoding($message, 'UTF-16', 'UTF-8'); $count = 0; //mostly taken from https://dynmark.uservoice.com/knowledgebase/articles/83496-gsm-alphabet-character-set $search = [ '`', '‘', '’', //single quotes '“', '”', //double quotes '~', '¬', '|', //misc chr(0xc2a0) //nbsp character ]; $replace = [ "'", "'", "'", //single quotes '"', '"', //double quotes '-', '-', 'I', //misc " " //space ]; $message = str_replace($search, $replace, $message, $count); $message = trim($message); return ['message' => $message, 'replacements' => $count]; } $message = "We can’t wait to see you at our Open Day next week. We’ve sent you an email with all the info you need. If you’ve not received it please call 01252 892883"; var_dump(stripNonValidCharaters($message));

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.0170.00316.75
8.3.50.0110.00722.12
8.3.40.0060.01218.67
8.3.30.0110.00418.65
8.3.20.0000.00820.16
8.3.10.0040.00420.53
8.3.00.0040.00419.25
8.2.180.0150.00316.37
8.2.170.0110.00718.90
8.2.160.0110.00322.96
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.66
8.2.110.0000.01019.11
8.2.100.0120.00017.78
8.2.90.0040.00419.57
8.2.80.0030.00617.63
8.2.70.0000.00917.63
8.2.60.0040.00418.05
8.2.50.0070.00418.07
8.2.40.0040.00418.34
8.2.30.0040.00418.05
8.2.20.0080.00017.70
8.2.10.0020.00518.11
8.2.00.0040.00417.73
8.1.280.0100.00725.92
8.1.270.0000.00920.54
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0070.00322.52
8.1.230.0030.00820.97
8.1.220.0040.00417.78
8.1.210.0040.00418.89
8.1.200.0030.00617.35
8.1.190.0000.00717.22
8.1.180.0000.00718.10
8.1.170.0070.00018.80
8.1.160.0030.00618.96
8.1.150.0070.00019.03
8.1.140.0050.00317.52
8.1.130.0000.00717.75
8.1.120.0070.00017.55
8.1.110.0000.00717.45
8.1.100.0030.00317.46
8.1.90.0030.00517.54
8.1.80.0000.00717.48
8.1.70.0030.00317.42
8.1.60.0030.00517.53
8.1.50.0060.00317.48
8.1.40.0030.00617.60
8.1.30.0040.00417.56
8.1.20.0050.00317.73
8.1.10.0000.00717.63
8.1.00.0080.00017.46
8.0.300.0030.00619.96
8.0.290.0050.00316.62
8.0.280.0000.00718.43
8.0.270.0050.00317.25
8.0.260.0030.00317.33
8.0.250.0000.00617.06
8.0.240.0030.00616.90
8.0.230.0000.00617.02
8.0.220.0020.00516.81
8.0.210.0030.00317.01
8.0.200.0070.00016.99
8.0.190.0000.00717.05
8.0.180.0030.00316.88
8.0.170.0070.00017.06
8.0.160.0000.00816.89
8.0.150.0000.00716.91
8.0.140.0030.00516.93
8.0.130.0040.00413.32
8.0.120.0050.00316.93
8.0.110.0000.00716.80
8.0.100.0040.00416.84
8.0.90.0000.00717.02
8.0.80.0060.01016.91
8.0.70.0000.00716.97
8.0.60.0040.00417.00
8.0.50.0030.00516.83
8.0.30.0060.01517.11
8.0.20.0080.01317.40
8.0.10.0040.00416.87
8.0.00.0110.00916.98
7.4.330.0000.00515.02
7.4.320.0060.00016.57
7.4.300.0000.00616.57
7.4.290.0000.00716.67
7.4.280.0050.00316.70
7.4.270.0030.00316.73
7.4.260.0040.00416.66
7.4.250.0000.00716.56
7.4.240.0030.00416.63
7.4.230.0070.00016.61
7.4.220.0100.01016.70
7.4.210.0090.01216.71
7.4.200.0000.00716.68
7.4.160.0060.01116.54
7.4.150.0120.00617.40
7.4.140.0100.00917.86
7.4.130.0120.00616.36
7.4.120.0060.01116.55
7.4.110.0160.00316.42
7.4.100.0140.00316.49
7.4.90.0130.00316.50
7.4.80.0070.01716.75
7.4.70.0060.00916.48
7.4.60.0100.00616.43
7.4.50.0000.00816.35
7.4.40.0140.01116.67
7.4.30.0060.01016.45
7.4.00.0030.01015.23
7.3.330.0060.00013.34
7.3.320.0030.00313.21
7.3.310.0000.00716.43
7.3.300.0000.00716.34
7.3.290.0060.00816.37
7.3.280.0080.00716.38
7.3.270.0160.00517.40
7.3.260.0120.00416.25
7.3.240.0120.01216.29
7.3.230.0100.01316.39
7.3.210.0080.00816.44
7.3.200.0150.00819.39
7.3.190.0090.00916.73
7.3.180.0120.00616.45
7.3.170.0130.01016.43
7.3.160.0090.01216.41
7.2.330.0110.00716.56
7.2.320.0130.00316.68
7.2.310.0140.00316.86
7.2.300.0030.01316.55
7.2.290.0100.00716.51
7.2.60.0040.00816.52
7.2.00.0030.01019.62
7.1.200.0030.00915.55
7.1.100.0030.01017.86
7.1.70.0060.00617.27
7.1.60.0120.01219.34
7.1.50.0090.01217.05
7.1.00.0070.07322.36
7.0.200.0000.00716.66
7.0.140.0030.07322.10
7.0.60.0000.08019.94
7.0.50.0100.05717.89
7.0.40.0100.06320.23
7.0.30.0230.07020.13
7.0.20.0300.06320.08
7.0.10.0130.08020.33
7.0.00.0070.06720.33
5.6.280.0000.07321.00
5.6.210.0030.08720.75
5.6.200.0030.04018.29
5.6.190.0100.07020.63
5.6.180.0170.04720.48
5.6.170.0370.06720.71
5.6.160.0030.08720.56
5.6.150.0030.04018.17
5.6.140.0100.06018.28
5.6.130.0100.07718.27
5.6.120.0070.08021.12
5.6.110.0100.08321.01
5.6.100.0000.05720.98
5.6.90.0070.05720.97
5.6.80.0030.03720.41
5.5.350.0270.08020.45
5.5.340.0070.04317.92
5.5.330.0030.08320.30
5.5.320.0230.04020.41
5.5.310.0300.07720.28
5.5.300.0230.05718.08
5.5.290.0030.08317.93
5.5.280.0100.08020.91
5.5.270.0130.03720.64
5.5.260.0100.06320.77
5.5.250.0070.03720.55
5.5.240.0230.06320.25
5.4.450.0170.05319.70
5.4.440.0870.05319.29
5.4.430.0700.07719.57
5.4.420.0100.05319.54
5.4.410.0130.05319.42
5.4.400.0230.05018.77
5.4.390.0270.05718.81
5.4.380.0400.05318.76
5.4.370.0230.06318.89
5.4.360.0430.06018.76
5.4.350.0220.09112.02
5.4.340.0090.04212.02
5.4.320.0180.08112.51
5.4.310.0160.06212.50
5.4.300.0220.06612.51
5.4.290.0160.08612.50
5.4.280.0190.08112.39
5.4.270.0060.04712.40
5.4.260.0120.04812.40
5.4.250.0140.05212.40
5.4.240.0100.05712.40
5.4.230.0220.08012.39
5.4.220.0290.07612.39
5.4.210.0170.07112.39
5.4.200.0130.04612.39
5.4.190.0190.04912.39
5.4.180.0150.07512.38
5.4.170.0130.04412.39
5.4.160.0140.08412.39
5.4.150.0110.06112.39
5.4.140.0090.06012.07
5.4.130.0110.04012.06
5.4.120.0070.04212.02
5.4.110.0040.05012.02
5.4.100.0110.06312.01
5.4.90.0060.04612.02
5.4.80.0060.03912.02
5.4.70.0040.05112.01
5.4.60.0060.04012.01
5.4.50.0080.05012.01
5.4.40.0080.05112.00
5.4.30.0100.04912.00
5.4.20.0100.05111.99
5.4.10.0080.05611.99
5.4.00.0110.05111.49
5.3.290.0090.04412.80
5.3.280.0080.04312.71
5.3.270.0070.05512.72
5.3.260.0080.05512.72
5.3.250.0120.05112.72
5.3.240.0050.04812.72
5.3.230.0060.04612.71
5.3.220.0070.04112.68
5.3.210.0090.04612.68
5.3.200.0080.04112.68
5.3.190.0130.03812.68
5.3.180.0120.04712.67
5.3.170.0100.06812.67
5.3.160.0120.04312.67
5.3.150.0060.04612.67
5.3.140.0110.03412.66
5.3.130.0080.03612.66
5.3.120.0080.04712.66
5.3.110.0070.04912.66
5.3.100.0100.04212.13
5.3.90.0120.04912.11
5.3.80.0060.05112.10
5.3.70.0070.05012.10
5.3.60.0140.05612.09
5.3.50.0140.08012.02
5.3.40.0110.04212.02
5.3.30.0080.04211.98
5.3.20.0110.03911.77
5.3.10.0070.03711.73
5.3.00.0090.04011.72
5.2.170.0070.0369.21
5.2.160.0090.0549.21
5.2.150.0080.0419.22
5.2.140.0140.0849.21
5.2.130.0070.0399.17
5.2.120.0050.0419.17
5.2.110.0070.0319.18
5.2.100.0050.0309.18
5.2.90.0080.0579.18
5.2.80.0070.0409.17
5.2.70.0080.0429.18
5.2.60.0100.0409.13
5.2.50.0080.0419.10
5.2.40.0080.0289.07
5.2.30.0110.0309.05
5.2.20.0080.0319.04
5.2.10.0100.0318.95
5.2.00.0050.0308.80
5.1.60.0050.0278.09
5.1.50.0080.0268.09
5.1.40.0050.0268.06
5.1.30.0030.0298.42
5.1.20.0050.0328.44
5.1.10.0080.0278.16
5.1.00.0020.0298.16
5.0.50.0050.0206.64
5.0.40.0070.0356.51
5.0.30.0040.0426.31
5.0.20.0070.0246.28
5.0.10.0080.0246.27
5.0.00.0120.0586.26
4.4.90.0060.0214.77
4.4.80.0070.0314.75
4.4.70.0030.0224.75
4.4.60.0030.0174.75
4.4.50.0040.0174.77
4.4.40.0040.0304.71
4.4.30.0040.0154.76
4.4.20.0090.0334.84
4.4.10.0070.0394.85
4.4.00.0050.0294.76
4.3.110.0070.0224.67
4.3.100.0070.0174.67
4.3.90.0020.0184.63
4.3.80.0070.0404.58
4.3.70.0050.0214.63
4.3.60.0040.0284.63
4.3.50.0090.0234.63
4.3.40.0040.0384.53
4.3.30.0080.0243.30
4.3.20.0000.0343.28
4.3.10.0020.0203.25
4.3.00.0070.0307.74

preferences:
61.8 ms | 401 KiB | 5 Q