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, 0x03d5, 0x00E8, 0x00E9, 0x00F9, 0x00EC, 0x00F2, 0x00E7, 0x00D8, 0x00A5 ]; for($i = 0; $i < strlen($message); $i++) { if(!in_array(hexdec(bin2hex(mb_substr($message, $i, 1))), $validGSMKeycodes, true)) { $message[$i] = ''; $count++; } } $message = trim($message); return ['message' => $message, 'replacements' => $count]; } $message= "@£\$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤%&'()*+,-./0123456789:;>=<?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüàExtended: €[\]^{|}~"; foreach(mb_list_encodings() as $chr){ echo mb_convert_encoding($message, 'UTF-8', $chr)." : ".$chr."\n"; } 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.0070.00719.06
8.3.50.0090.01122.13
8.3.40.0080.00819.20
8.3.30.0110.00419.73
8.3.20.0040.00420.54
8.3.10.0040.00423.72
8.3.00.0060.00319.76
8.2.180.0130.00717.25
8.2.170.0070.00722.96
8.2.160.0070.01020.65
8.2.150.0030.00524.18
8.2.140.0060.00324.66
8.2.130.0050.00326.16
8.2.120.0040.00422.35
8.2.110.0040.01822.46
8.2.100.0040.00818.28
8.2.90.0050.00319.47
8.2.80.0060.00319.48
8.2.70.0060.00318.00
8.2.60.0090.00018.30
8.2.50.0030.00518.30
8.2.40.0110.00320.50
8.2.30.0040.00418.50
8.2.20.0040.00418.09
8.2.10.0000.00718.55
8.2.00.0060.00318.06
8.1.280.0070.01025.92
8.1.270.0030.00622.62
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0150.00623.00
8.1.230.0000.01118.08
8.1.220.0080.00018.03
8.1.210.0060.00318.77
8.1.200.0000.01017.85
8.1.190.0030.00517.85
8.1.180.0080.00018.16
8.1.170.0040.00419.09
8.1.160.0040.00419.45
8.1.150.0000.00819.37
8.1.140.0000.00817.88
8.1.130.0080.00018.27
8.1.120.0040.00417.94
8.1.110.0000.00817.81
8.1.100.0000.00817.95
8.1.90.0000.00818.02
8.1.80.0000.00817.96
8.1.70.0000.00717.93
8.1.60.0060.00317.90
8.1.50.0030.00617.96
8.1.40.0050.00517.85
8.1.30.0040.00418.09
8.1.20.0000.00817.89
8.1.10.0030.00617.96
8.1.00.0040.00417.90
8.0.300.0030.00518.77
8.0.290.0080.00417.13
8.0.280.0030.00518.67
8.0.270.0050.00217.56
8.0.260.0000.00817.50
8.0.250.0030.00317.17
8.0.240.0090.00017.19
8.0.230.0000.00717.29
8.0.220.0050.00217.00
8.0.210.0040.00417.04
8.0.200.0020.00517.20
8.0.190.0060.00317.29
8.0.180.0030.00617.12
8.0.170.0000.00817.15
8.0.160.0000.00817.19
8.0.150.0040.00417.18
8.0.140.0000.00817.21
8.0.130.0060.00013.65
8.0.120.0050.00217.18
8.0.110.0040.00417.29
8.0.100.0050.00317.20
8.0.90.0040.00417.21
8.0.80.0100.00617.33
8.0.70.0040.00417.32
8.0.60.0030.00617.13
8.0.50.0040.00417.23
8.0.30.0090.01317.39
8.0.20.0150.00817.46
8.0.10.0040.00417.43
8.0.00.0090.01017.12
7.4.330.0000.00515.26
7.4.320.0000.00716.93
7.4.300.0030.00316.79
7.4.290.0030.00516.78
7.4.280.0050.00316.75
7.4.270.0080.00016.79
7.4.260.0040.00416.84
7.4.250.0000.00816.90
7.4.240.0030.00516.88
7.4.230.0070.00016.90
7.4.220.0090.01016.87
7.4.210.0110.01117.04
7.4.200.0050.00216.82
7.4.160.0110.00716.79
7.4.150.0060.01617.40
7.4.140.0100.00917.86
7.4.130.0100.01116.84
7.4.120.0160.00616.79
7.4.110.0130.00716.77
7.4.100.0080.01116.80
7.4.90.0170.00417.01
7.4.80.0090.01419.39
7.4.70.0060.01416.96
7.4.60.0100.01316.73
7.4.50.0030.00616.98
7.4.40.0140.00316.70
7.4.30.0080.01116.93
7.4.00.0100.00715.36
7.3.330.0060.00013.51
7.3.320.0000.00613.66
7.3.310.0030.00516.61
7.3.300.0040.00416.42
7.3.290.0120.00416.61
7.3.280.0100.01016.59
7.3.270.0120.01517.40
7.3.260.0190.00016.70
7.3.250.0110.01516.71
7.3.240.0070.01116.76
7.3.230.0120.00916.82
7.3.210.0090.01316.73
7.3.200.0070.01719.39
7.3.190.0200.00016.83
7.3.180.0150.00316.88
7.3.170.0080.01116.75
7.3.160.0070.01016.89
7.3.10.0130.00317.02
7.3.00.0030.01016.92
7.2.330.0100.01017.00
7.2.320.0130.00617.06
7.2.310.0140.00416.97
7.2.300.0110.00717.02
7.2.290.0040.01817.13
7.2.130.0040.00816.94
7.2.120.0030.01617.24
7.2.110.0040.00817.18
7.2.100.0090.00617.17
7.2.90.0100.00717.29
7.2.80.0060.00817.29
7.2.70.0060.00917.24
7.2.60.0110.00317.00
7.2.50.0150.00316.87
7.2.40.0100.00017.34
7.2.30.0000.01817.29
7.2.20.0060.00317.16
7.2.10.0000.01417.19
7.2.00.0080.00918.46
7.1.250.0030.01015.78
7.1.200.0070.00716.08
7.1.100.0110.00018.63
7.1.70.0000.01617.34
7.1.60.0070.01819.19
7.1.50.0100.01417.34
7.1.00.0030.07322.44
7.0.200.0020.00517.09
7.0.140.0000.07721.95
7.0.60.0030.04319.97
7.0.50.0100.08317.98
7.0.40.0030.04320.09
7.0.30.0370.04720.09
7.0.20.0330.06320.16
7.0.10.0100.06320.13
7.0.00.0070.06020.18
5.6.280.0130.06721.10
5.6.210.0170.07720.50
5.6.200.0100.05018.18
5.6.190.0030.05020.56
5.6.180.0200.06020.48
5.6.170.0200.07020.56
5.6.160.0070.07720.55
5.6.150.0100.07718.26
5.6.140.0030.04018.24
5.6.130.0100.06718.27
5.6.120.0030.04321.16
5.6.110.0070.08321.06
5.6.100.0100.08321.13
5.6.90.0100.07021.04
5.6.80.0000.07720.45
5.6.70.3530.03720.55
5.5.350.0370.07720.36
5.5.340.0130.07017.95
5.5.330.0100.05320.26
5.5.320.0370.07020.36
5.5.310.0270.07020.34
5.5.300.0130.07717.95
5.5.290.0030.07018.04
5.5.280.0070.08320.88
5.5.270.0100.07020.80
5.5.260.0200.06320.90
5.5.250.0030.04020.62
5.5.240.3930.03320.32
5.4.450.0800.04319.59
5.4.440.0670.07019.47
5.4.430.0830.06019.58
5.4.420.0130.05319.30
5.4.410.0570.06319.46
5.4.400.0830.05719.15
5.4.390.0770.05319.16
5.4.380.0700.06019.25
5.4.370.0630.06019.23
5.4.360.0900.06319.24
5.4.350.0700.05719.38
5.4.340.0020.04512.07
5.4.320.0090.03712.55
5.4.310.0120.04112.55
5.4.300.0060.03912.56
5.4.290.0100.03912.55
5.4.280.0070.03912.45
5.4.270.0080.03812.45
5.4.260.0050.04212.45
5.4.250.0060.04112.45
5.4.240.0090.03612.45
5.4.230.0070.04812.44
5.4.220.0100.04312.44
5.4.210.0120.04212.44
5.4.200.0080.03812.44
5.4.190.0100.04012.44
5.4.180.0080.03612.44
5.4.170.0090.03812.44
5.4.160.0060.04012.44
5.4.150.0060.03912.43
5.4.140.0100.03512.12
5.4.130.0080.04412.11
5.4.120.0050.04012.07
5.4.110.0080.03812.06
5.4.100.0080.04112.06
5.4.90.0120.05312.06
5.4.80.0070.03712.06
5.4.70.0060.03712.05
5.4.60.0100.03812.06
5.4.50.0080.03412.05
5.4.40.0060.03512.04
5.4.30.0080.03412.04
5.4.20.0060.03612.04
5.4.10.0080.03412.04
5.4.00.0090.03811.54
5.3.290.0080.03812.80
5.3.280.0070.03712.71
5.3.270.0040.04112.73
5.3.260.0090.03812.72
5.3.250.0050.04012.72
5.3.240.0080.03512.72
5.3.230.0090.03512.71
5.3.220.0060.03712.68
5.3.210.0060.03812.68
5.3.200.0090.03812.68
5.3.190.0020.04012.68
5.3.180.0070.04112.68
5.3.170.0070.03912.67
5.3.160.0100.03112.68
5.3.150.0090.03312.68
5.3.140.0040.03912.66
5.3.130.0040.04012.66
5.3.120.0060.03812.66
5.3.110.0100.03412.66
5.3.100.0010.04112.13
5.3.90.0060.03412.11
5.3.80.0080.04012.09
5.3.70.0070.03412.09
5.3.60.0080.03312.08
5.3.50.0090.03212.02
5.3.40.0050.03712.02
5.3.30.0040.03711.98
5.3.20.0070.03511.77
5.3.10.0050.03811.74
5.3.00.0060.03611.71
5.2.170.0030.0329.22
5.2.160.0020.0329.22
5.2.150.0030.0329.22
5.2.140.0020.0339.21
5.2.130.0030.0309.18
5.2.120.0040.0299.18
5.2.110.0040.0309.18
5.2.100.0040.0299.18
5.2.90.0020.0319.18
5.2.80.0050.0309.17
5.2.70.0070.0289.17
5.2.60.0020.0339.13
5.2.50.0030.0339.10
5.2.40.0050.0319.07
5.2.30.0040.0379.05
5.2.20.0050.0289.05
5.2.10.0020.0308.95
5.2.00.0070.0268.81
5.1.60.0060.0218.09
5.1.50.0040.0258.09
5.1.40.0030.0268.07
5.1.30.0060.0248.42
5.1.20.0040.0268.44
5.1.10.0050.0258.16
5.1.00.0050.0268.16
5.0.50.0020.0226.64
5.0.40.0050.0176.50
5.0.30.0020.0326.32
5.0.20.0040.0196.28
5.0.10.0050.0196.27
5.0.00.0020.0326.26
4.4.90.0030.0164.78
4.4.80.0010.0174.75
4.4.70.0030.0174.76
4.4.60.0040.0214.76
4.4.50.0050.0174.77
4.4.40.0020.0264.71
4.4.30.0050.0144.76
4.4.20.0020.0154.85
4.4.10.0030.0154.85
4.4.00.0030.0244.76
4.3.110.0040.0144.67
4.3.100.0030.0164.66
4.3.90.0050.0124.64
4.3.80.0020.0254.58
4.3.70.0030.0144.63
4.3.60.0050.0124.62
4.3.50.0050.0134.62
4.3.40.0030.0234.53
4.3.30.0010.0173.30
4.3.20.0020.0163.28
4.3.10.0000.0183.24
4.3.00.0030.0208.11

preferences:
46.52 ms | 401 KiB | 5 Q