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 ]; $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 < mb_strlen($message, 'UTF-16'); $i+=2) { echo mb_substr($message, $i, 1, 'UTF-16') . ' - '. hexdec(bin2hex(mb_substr($message, $i, 1, 'UTF-16'))). "\n"; if(!in_array(hexdec(bin2hex(mb_substr($message, $i, 1, 'UTF-16'))), $validGSMKeycodes, true)) { $message[$i] = ''; $count++; } } $message = mb_convert_encoding($message, 'UTF-8', 'UTF-16'); $message = trim($message); return ['message' => $message, 'replacements' => $count]; } $message= "@£\$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤%&'()*+,-./0123456789:;>=<?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüàExtended: €[\]^{|}~"; 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.40.0130.00318.96
8.3.30.0120.00319.23
8.3.20.0000.00820.05
8.3.10.0040.00423.66
8.3.00.0080.00019.51
8.2.170.0080.00822.96
8.2.160.0070.00720.35
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00422.31
8.2.110.0030.00721.91
8.2.100.0080.00417.75
8.2.90.0000.00919.23
8.2.80.0100.00017.97
8.2.70.0030.00717.88
8.2.60.0060.00318.05
8.2.50.0060.00318.07
8.2.40.0000.00818.16
8.2.30.0040.00418.23
8.2.20.0040.00417.90
8.2.10.0000.00818.21
8.2.00.0000.00817.78
8.1.270.0060.00322.25
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00323.79
8.1.230.0060.00619.14
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00717.35
8.1.190.0080.00017.24
8.1.180.0030.00618.10
8.1.170.0070.00318.55
8.1.160.0000.00822.12
8.1.150.0050.00319.01
8.1.140.0050.00317.47
8.1.130.0040.00417.79
8.1.120.0090.00017.50
8.1.110.0040.00417.46
8.1.100.0050.00317.61
8.1.90.0000.00817.61
8.1.80.0050.00217.55
8.1.70.0040.00417.42
8.1.60.0080.00017.68
8.1.50.0060.00317.63
8.1.40.0050.00317.63
8.1.30.0030.00517.62
8.1.20.0040.00417.74
8.1.10.0030.00617.68
8.1.00.0050.00317.63
8.0.300.0050.00318.77
8.0.290.0040.00417.00
8.0.280.0040.00418.42
8.0.270.0040.00417.37
8.0.260.0000.00717.36
8.0.250.0000.00717.05
8.0.240.0040.00417.00
8.0.230.0000.00717.18
8.0.220.0000.00716.99
8.0.210.0040.00416.96
8.0.200.0050.00317.00
8.0.190.0080.00017.19
8.0.180.0000.00816.98
8.0.170.0000.00817.10
8.0.160.0000.00816.96
8.0.150.0000.00816.97
8.0.140.0030.00616.90
8.0.130.0030.00313.53
8.0.120.0050.00317.02
8.0.110.0080.00017.11
8.0.100.0030.00517.06
8.0.90.0080.00016.93
8.0.80.0030.01317.04
8.0.70.0060.00316.91
8.0.60.0040.00416.95
8.0.50.0080.00016.93
8.0.30.0150.00517.09
8.0.20.0110.01317.41
8.0.10.0090.00017.06
8.0.00.0120.00916.83
7.4.330.0030.00315.14
7.4.320.0000.00616.71
7.4.300.0000.00616.62
7.4.290.0000.00716.71
7.4.280.0080.00016.56
7.4.270.0040.00416.61
7.4.260.0050.00216.49
7.4.250.0050.00516.69
7.4.240.0020.00516.63
7.4.230.0040.00416.79
7.4.220.0130.00616.78
7.4.210.0100.00616.75
7.4.200.0000.00716.51
7.4.160.0140.00416.69
7.4.150.0120.01517.40
7.4.140.0110.00917.86
7.4.130.0120.00616.69
7.4.120.0110.01116.63
7.4.110.0040.01516.78
7.4.100.0220.00416.55
7.4.90.0090.01416.74
7.4.80.0150.00919.39
7.4.70.0100.01016.64
7.4.60.0150.00416.78
7.4.50.0060.00316.61
7.4.40.0090.00916.69
7.4.30.0070.01116.51
7.4.00.0000.01415.18
7.3.330.0030.00313.46
7.3.320.0030.00313.34
7.3.310.0000.00816.55
7.3.300.0000.00716.43
7.3.290.0080.00716.49
7.3.280.0100.00616.55
7.3.270.0090.01217.40
7.3.260.0130.00716.61
7.3.250.0100.00916.66
7.3.240.0140.01016.55
7.3.230.0070.01616.48
7.3.210.0040.01716.48
7.3.200.0090.01019.39
7.3.190.0140.00816.48
7.3.180.0090.00916.45
7.3.170.0100.01016.56
7.3.160.0000.02116.60
7.2.330.0120.00916.55
7.2.320.0100.00916.70
7.2.310.0070.01116.72
7.2.300.0080.01116.68
7.2.290.0090.01116.84
7.2.60.0000.00917.13
7.2.00.0030.01019.57
7.1.200.0240.00315.92
7.1.70.0000.00816.92
7.1.60.0040.00717.35
7.1.50.0040.01416.91
7.1.00.0000.08022.54
7.0.200.0110.00416.88
7.0.140.0070.07322.11
7.0.60.0100.04319.84
7.0.50.0000.04717.91
7.0.40.0030.04320.09
7.0.30.0500.07320.34
7.0.20.0400.07320.06
7.0.10.0030.09320.25
7.0.00.0000.08320.12
5.6.280.0030.07720.82
5.6.210.0070.08020.68
5.6.200.0070.04718.29
5.6.190.0100.04020.67
5.6.180.0100.05720.58
5.6.170.0230.05720.44
5.6.160.0130.05020.57
5.6.150.0100.04018.15
5.6.140.0130.07718.14
5.6.130.0070.04318.15
5.6.120.0030.04320.93
5.6.110.0030.09021.18
5.6.100.0000.04321.02
5.6.90.0130.07321.14
5.6.80.0100.08020.44
5.6.70.3370.02320.41
5.5.350.0330.07020.37
5.5.340.0030.04318.09
5.5.330.0170.06720.27
5.5.320.0330.04720.46
5.5.310.0200.08020.27
5.5.300.0070.05317.98
5.5.290.0170.06718.08
5.5.280.0130.03020.80
5.5.270.0130.07020.83
5.5.260.0230.07020.82
5.5.250.0000.05020.65
5.5.240.4370.04020.39
5.4.450.0230.06319.20
5.4.440.0670.07019.48
5.4.430.0770.05019.45
5.4.420.0730.06019.44
5.4.410.0500.06719.43
5.4.400.0630.05319.15
5.4.390.0170.05318.98
5.4.380.0600.05719.38
5.4.370.0900.05719.06
5.4.360.0830.06019.15
5.4.350.0500.07719.26
5.4.340.0060.03512.05
5.4.320.0050.03812.55
5.4.310.0100.03512.54
5.4.300.0050.03912.54
5.4.290.0060.03912.54
5.4.280.0050.03712.44
5.4.270.0060.03712.44
5.4.260.0090.03512.44
5.4.250.0070.04112.44
5.4.240.0040.03812.43
5.4.230.0070.04012.43
5.4.220.0080.03512.43
5.4.210.0070.03512.43
5.4.200.0080.03712.43
5.4.190.0060.03612.43
5.4.180.0070.03512.42
5.4.170.0040.03912.44
5.4.160.0040.03812.43
5.4.150.0040.03912.42
5.4.140.0040.03912.11
5.4.130.0090.03412.09
5.4.120.0110.03112.06
5.4.110.0080.03412.05
5.4.100.0080.03812.05
5.4.90.0020.04212.05
5.4.80.0050.03912.05
5.4.70.0040.04112.04
5.4.60.0070.03412.05
5.4.50.0040.03812.05
5.4.40.0030.03912.03
5.4.30.0070.04712.03
5.4.20.0060.03912.03
5.4.10.0050.03612.03
5.4.00.0060.03611.52
5.3.290.0050.04012.80
5.3.280.0050.04012.71
5.3.270.0130.03412.72
5.3.260.0070.04312.72
5.3.250.0100.03412.72
5.3.240.0070.03712.72
5.3.230.0080.03912.71
5.3.220.0050.04012.68
5.3.210.0070.04312.68
5.3.200.0060.04012.68
5.3.190.0020.04412.68
5.3.180.0080.03912.67
5.3.170.0080.03912.66
5.3.160.0090.03212.67
5.3.150.0050.03812.68
5.3.140.0070.03512.66
5.3.130.0060.03812.66
5.3.120.0070.03712.65
5.3.110.0060.03912.66
5.3.100.0080.03412.13
5.3.90.0040.03712.11
5.3.80.0120.03012.10
5.3.70.0040.04012.09
5.3.60.0080.03412.08
5.3.50.0040.03912.02
5.3.40.0090.03412.02
5.3.30.0050.03611.98
5.3.20.0040.03711.77
5.3.10.0060.04511.73
5.3.00.0080.05111.72
5.2.170.0080.0409.22
5.2.160.0070.0329.22
5.2.150.0050.0309.22
5.2.140.0030.0329.21
5.2.130.0050.0319.18
5.2.120.0060.0399.18
5.2.110.0050.0289.19
5.2.100.0060.0279.18
5.2.90.0050.0289.18
5.2.80.0060.0299.18
5.2.70.0050.0319.18
5.2.60.0040.0349.13
5.2.50.0070.0279.10
5.2.40.0070.0309.08
5.2.30.0010.0349.05
5.2.20.0060.0319.04
5.2.10.0050.0288.95
5.2.00.0050.0358.81
5.1.60.0050.0238.09
5.1.50.0050.0238.09
5.1.40.0080.0278.07
5.1.30.0060.0258.42
5.1.20.0060.0248.44
5.1.10.0090.0268.16
5.1.00.0050.0278.16
5.0.50.0030.0216.65
5.0.40.0030.0206.51
5.0.30.0040.0316.31
5.0.20.0040.0196.28
5.0.10.0020.0216.27
5.0.00.0040.0316.26
4.4.90.0030.0214.78
4.4.80.0020.0304.76
4.4.70.0040.0244.76
4.4.60.0020.0244.75
4.4.50.0040.0164.77
4.4.40.0030.0274.71
4.4.30.0040.0154.76
4.4.20.0010.0194.84
4.4.10.0020.0204.85
4.4.00.0010.0284.76
4.3.110.0050.0204.67
4.3.100.0030.0144.66
4.3.90.0030.0204.64
4.3.80.0060.0244.58
4.3.70.0040.0204.63
4.3.60.0040.0204.63
4.3.50.0020.0204.63
4.3.40.0040.0244.53
4.3.30.0030.0203.30
4.3.20.0040.0163.28
4.3.10.0010.0173.25
4.3.00.0130.0238.13

preferences:
43.24 ms | 400 KiB | 5 Q