3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stripNonValidCharaters ($message) { $count = 0; //mostly taken from https://dynmark.uservoice.com/knowledgebase/articles/83496-gsm-alphabet-character-set $search = [ '`', '‘', '’', //single quotes '“', '”', //double quotes '~', '¬', '|' //misc ]; $replace = [ '\'', '\'', '\'', //single quotes '"', '"', //double quotes '-', '-', 'I' //misc ]; $message = str_replace($search, $replace, $message, $count); $validGSMKeycodes = [ 0x0040, 0x0394, 0x0020, 0x0030, 0x00a1, 0x0050, 0x00bf, 0x0070, 0x00a3, 0x005f, 0x0021, 0x0031, 0x0041, 0x0051, 0x0061, 0x0071, 0x0024, 0x03a6, 0x0022, 0x0032, 0x0042, 0x0052, 0x0062, 0x0072, 0x00a5, 0x0393, 0x0023, 0x0033, 0x0043, 0x0053, 0x0063, 0x0073, 0x00e8, 0x039b, 0x00a4, 0x0034, 0x0035, 0x0044, 0x0054, 0x0064, 0x0074, 0x00e9, 0x03a9, 0x0025, 0x0045, 0x0045, 0x0055, 0x0065, 0x0075, 0x00f9, 0x03a0, 0x0026, 0x0036, 0x0046, 0x0056, 0x0066, 0x0076, 0x00ec, 0x03a8, 0x0027, 0x0037, 0x0047, 0x0057, 0x0067, 0x0077, 0x00f2, 0x03a3, 0x0028, 0x0038, 0x0048, 0x0058, 0x0068, 0x0078, 0x00c7, 0x0398, 0x0029, 0x0039, 0x0049, 0x0059, 0x0069, 0x0079, 0x000a, 0x039e, 0x002a, 0x003a, 0x004a, 0x005a, 0x006a, 0x007a, 0x00d8, 0x001b, 0x002b, 0x003b, 0x004b, 0x00c4, 0x006b, 0x00e4, 0x00f8, 0x00c6, 0x002c, 0x003c, 0x004c, 0x00d6, 0x006c, 0x00f6, 0x000d, 0x00e6, 0x002d, 0x003d, 0x004d, 0x00d1, 0x006d, 0x00f1, 0x00c5, 0x00df, 0x002e, 0x003e, 0x004e, 0x00dc, 0x006e, 0x00fc, 0x00e5, 0x00c9, 0x002f, 0x003f, 0x004f, 0x00a7, 0x006f, 0x00e0 ]; for($i = 0; $i < strlen($message); $i++) { if(!in_array(hexdec(bin2hex(mb_substr($message, $i, 1))), $validGSMKeycodes, true)) { $message[$i] = ''; $count++; } } return ['message' => $message, 'replacements' => $count]; } $msg = "“This’ll be awesome” said the Times."; $tmp['message'] = ''; while ($tmp['message'] != $msg) { $tmp = stripNonValidCharaters($msg); $msg = $tmp['message']; } var_dump(trim($msg));

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.63
8.3.50.0180.00321.98
8.3.40.0140.00718.79
8.3.30.0070.00719.22
8.3.20.0000.00820.29
8.3.10.0040.00423.73
8.3.00.0080.00019.38
8.2.180.0140.00718.41
8.2.170.0070.01422.96
8.2.160.0090.00620.47
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0040.00422.10
8.2.110.0030.00622.12
8.2.100.0030.00919.02
8.2.90.0040.00417.88
8.2.80.0080.00017.97
8.2.70.0060.00318.04
8.2.60.0040.00417.93
8.2.50.0080.00018.10
8.2.40.0050.00220.59
8.2.30.0040.00418.28
8.2.20.0050.00217.66
8.2.10.0020.00518.16
8.2.00.0050.00217.84
8.1.280.0100.00725.92
8.1.270.0030.00623.87
8.1.260.0070.00026.35
8.1.250.0020.00528.09
8.1.240.0070.01422.24
8.1.230.0110.00019.15
8.1.220.0060.00317.74
8.1.210.0050.00318.77
8.1.200.0000.00817.36
8.1.190.0080.00317.25
8.1.180.0050.00518.10
8.1.170.0000.00818.50
8.1.160.0040.00421.93
8.1.150.0040.00418.81
8.1.140.0040.00417.38
8.1.130.0030.00317.75
8.1.120.0020.00517.52
8.1.110.0050.00317.50
8.1.100.0000.00717.55
8.1.90.0040.00417.50
8.1.80.0040.00417.39
8.1.70.0000.00717.49
8.1.60.0000.00817.68
8.1.50.0030.00517.62
8.1.40.0000.00917.64
8.1.30.0050.00317.74
8.1.20.0040.00417.59
8.1.10.0000.00717.58
8.1.00.0000.00717.61
8.0.300.0000.00819.53
8.0.290.0040.00417.00
8.0.280.0000.00818.54
8.0.270.0070.00017.37
8.0.260.0030.00317.33
8.0.250.0000.00717.05
8.0.240.0030.00316.99
8.0.230.0030.00317.03
8.0.220.0040.00416.91
8.0.210.0080.00016.88
8.0.200.0000.00717.04
8.0.190.0000.00717.03
8.0.180.0040.00416.89
8.0.170.0000.00817.05
8.0.160.0080.00017.04
8.0.150.0030.00316.95
8.0.140.0030.00516.86
8.0.130.0000.00613.41
8.0.120.0040.00416.98
8.0.110.0040.00417.05
8.0.100.0000.00717.00
8.0.90.0050.00317.04
8.0.80.0140.00717.00
8.0.70.0000.01016.84
8.0.60.0070.00016.83
8.0.50.0030.00516.90
8.0.30.0100.01016.96
8.0.20.0060.01417.40
8.0.10.0040.00417.04
8.0.00.0120.00916.85
7.4.330.0030.00315.10
7.4.320.0070.00016.73
7.4.300.0000.00716.46
7.4.290.0070.00016.57
7.4.280.0040.00416.53
7.4.270.0000.00716.55
7.4.260.0080.00016.54
7.4.250.0050.00316.66
7.4.240.0070.00016.60
7.4.230.0000.00716.45
7.4.220.0060.01216.58
7.4.210.0030.01316.63
7.4.200.0040.00416.73
7.4.160.0110.00616.70
7.4.150.0120.00617.40
7.4.140.0110.00817.86
7.4.130.0150.00616.68
7.4.120.0090.00816.51
7.4.110.0100.00716.51
7.4.100.0000.01716.68
7.4.90.0180.00716.64
7.4.80.0150.00719.39
7.4.70.0080.00816.57
7.4.60.0030.01316.62
7.4.50.0050.00016.23
7.4.40.0140.00616.54
7.4.30.0130.00716.59
7.4.00.0000.01215.23
7.3.330.0000.00713.24
7.3.320.0020.00213.52
7.3.310.0070.00016.28
7.3.300.0040.00416.25
7.3.290.0080.01216.43
7.3.280.0130.00616.41
7.3.270.0060.01517.40
7.3.260.0090.00916.59
7.3.240.0110.01416.54
7.3.230.0000.01916.43
7.3.210.0030.01316.48
7.3.200.0060.01619.39
7.3.190.0120.00916.43
7.3.180.0030.01216.53
7.3.170.0100.00716.44
7.3.160.0060.00916.53
7.3.10.0070.00716.78
7.3.00.0090.00316.77
7.2.330.0100.00716.65
7.2.320.0090.00816.66
7.2.310.0120.00616.67
7.2.300.0100.01016.52
7.2.290.0100.00716.73
7.2.130.0000.01317.00
7.2.120.0090.00617.15
7.2.110.0000.01216.98
7.2.100.0110.00417.14
7.2.90.0040.01416.64
7.2.80.0080.00316.83
7.2.70.0070.00417.09
7.2.60.0070.00517.03
7.2.50.0040.01116.70
7.2.40.0040.00816.93
7.2.30.0060.00916.88
7.2.20.0080.00816.89
7.2.10.0030.00916.66
7.2.00.0050.01018.15
7.1.250.0070.00715.80
7.1.200.0070.00715.59
7.1.100.0060.00618.24
7.1.70.0030.00716.84
7.1.60.0090.01519.32
7.1.50.0070.01017.02
7.1.00.0030.07722.35
7.0.200.0020.00516.78
7.0.140.0070.07022.19
7.0.60.0170.06320.05
7.0.50.0100.03317.91
7.0.40.0200.04019.96
7.0.30.0300.04720.12
7.0.20.0270.08720.08
7.0.10.0070.08320.12
7.0.00.0130.05720.23
5.6.280.0000.07720.94
5.6.210.0030.07020.78
5.6.200.0030.04018.13
5.6.190.0030.04720.43
5.6.180.0300.07320.50
5.6.170.0330.06020.52
5.6.160.0100.07020.49
5.6.150.0100.05018.21
5.6.140.0070.03718.24
5.6.130.0070.05318.18
5.6.120.0170.07020.83
5.6.110.0100.06720.91
5.6.100.0170.05721.02
5.6.90.0070.05321.02
5.6.80.0170.06720.53
5.5.350.0170.06320.45
5.5.340.0130.07317.96
5.5.330.0100.04720.28
5.5.320.0470.07020.34
5.5.310.0070.04720.34
5.5.300.0030.04018.02
5.5.290.0030.04717.98
5.5.280.0130.08020.90
5.5.270.0070.06020.80
5.5.260.0100.07720.75
5.5.250.0100.07020.71
5.5.240.0170.03720.38
5.4.450.0930.06019.35
5.4.440.0700.06019.43
5.4.430.0800.05019.58
5.4.420.0700.00019.52
5.4.410.0670.00019.46
5.4.400.0630.00019.21
5.4.390.0630.00019.16
5.4.380.0670.00019.07
5.4.370.0630.00019.16
5.4.360.0670.00019.07
5.4.350.0630.00019.12
5.4.340.0070.03412.04
5.4.320.0040.04312.54
5.4.310.0050.03912.53
5.4.300.0070.03612.54
5.4.290.0060.03912.54
5.4.280.0050.03712.43
5.4.270.0090.03312.43
5.4.260.0060.03912.43
5.4.250.0040.03812.43
5.4.240.0070.03412.43
5.4.230.0050.04112.43
5.4.220.0080.03412.42
5.4.210.0040.03712.42
5.4.200.0070.04012.43
5.4.190.0050.03712.41
5.4.180.0070.03512.42
5.4.170.0060.04012.42
5.4.160.0060.03612.42
5.4.150.0080.03512.41
5.4.140.0050.03912.10
5.4.130.0040.03812.09
5.4.120.0060.03512.04
5.4.110.0050.03612.04
5.4.100.0080.03312.04
5.4.90.0070.03612.04
5.4.80.0050.03812.04
5.4.70.0060.03412.04
5.4.60.0030.04012.03
5.4.50.0050.03812.04
5.4.40.0070.04912.03
5.4.30.0070.04312.02
5.4.20.0120.04412.02
5.4.10.0100.03312.02
5.4.00.0070.03611.51
5.3.290.0050.03912.80
5.3.280.0100.03412.71
5.3.270.0080.03712.73
5.3.260.0030.04112.72
5.3.250.0060.03712.72
5.3.240.0070.03812.72
5.3.230.0050.03812.71
5.3.220.0060.03912.68
5.3.210.0110.03312.68
5.3.200.0070.03512.68
5.3.190.0060.04012.68
5.3.180.0100.05012.68
5.3.170.0070.03512.67
5.3.160.0050.03712.68
5.3.150.0070.03712.67
5.3.140.0080.03412.66
5.3.130.0060.03812.66
5.3.120.0060.03912.66
5.3.110.0100.03512.66
5.3.100.0100.03212.13
5.3.90.0040.03812.11
5.3.80.0050.03712.09
5.3.70.0080.03812.09
5.3.60.0060.03912.09
5.3.50.0080.03512.02
5.3.40.0080.03812.02
5.3.30.0080.03311.98
5.3.20.0090.03211.76
5.3.10.0080.03211.74
5.3.00.0020.03911.71
5.2.170.0040.0319.22
5.2.160.0040.0309.21
5.2.150.0070.0299.22
5.2.140.0080.0289.21
5.2.130.0030.0329.18
5.2.120.0030.0389.17
5.2.110.0050.0359.19
5.2.100.0050.0299.18
5.2.90.0080.0319.18
5.2.80.0030.0339.18
5.2.70.0070.0389.18
5.2.60.0110.0319.13
5.2.50.0090.0459.09
5.2.40.0030.0339.07
5.2.30.0070.0319.05
5.2.20.0060.0279.04
5.2.10.0050.0288.95
5.2.00.0160.0488.80
5.1.60.0050.0298.09
5.1.50.0020.0298.09
5.1.40.0060.0268.07
5.1.30.0080.0278.42
5.1.20.0030.0308.44
5.1.10.0040.0288.16
5.1.00.0020.0278.16
5.0.50.0030.0206.64
5.0.40.0070.0166.50
5.0.30.0020.0326.31
5.0.20.0010.0226.29
5.0.10.0030.0246.26
5.0.00.0040.0326.25
4.4.90.0030.0154.78
4.4.80.0030.0154.75
4.4.70.0030.0154.75
4.4.60.0010.0174.75
4.4.50.0020.0164.77
4.4.40.0040.0244.71
4.4.30.0020.0164.76
4.4.20.0020.0164.84
4.4.10.0030.0154.85
4.4.00.0020.0264.76
4.3.110.0020.0174.67
4.3.100.0010.0204.66
4.3.90.0030.0154.63
4.3.80.0030.0244.58
4.3.70.0020.0154.63
4.3.60.0030.0144.63
4.3.50.0040.0304.63
4.3.40.0060.0444.54
4.3.30.0010.0203.30
4.3.20.0020.0163.28
4.3.10.0030.0183.24
4.3.00.0100.0277.32

preferences:
40.46 ms | 401 KiB | 5 Q