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))), $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.60.0090.00618.68
8.3.50.0070.01221.16
8.3.40.0150.00418.82
8.3.30.0110.00319.12
8.3.20.0040.00420.16
8.3.10.0080.00023.61
8.3.00.0080.00019.50
8.2.180.0140.00318.54
8.2.170.0150.00322.96
8.2.160.0030.01020.52
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0070.00022.18
8.2.110.0060.00322.20
8.2.100.0120.00017.75
8.2.90.0050.00219.25
8.2.80.0040.00417.97
8.2.70.0040.00717.50
8.2.60.0060.00317.93
8.2.50.0040.00718.07
8.2.40.0000.00818.28
8.2.30.0030.00518.11
8.2.20.0000.00817.91
8.2.10.0040.00418.20
8.2.00.0040.00417.89
8.1.280.0070.00725.92
8.1.270.0000.00822.02
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0000.00923.97
8.1.230.0090.00319.13
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0070.00317.48
8.1.190.0050.00317.47
8.1.180.0000.00718.10
8.1.170.0080.00018.63
8.1.160.0000.00722.10
8.1.150.0000.00718.89
8.1.140.0000.00817.57
8.1.130.0080.00017.88
8.1.120.0000.00817.53
8.1.110.0000.00717.58
8.1.100.0070.00017.61
8.1.90.0040.00417.61
8.1.80.0030.00317.56
8.1.70.0030.00317.53
8.1.60.0030.00617.64
8.1.50.0030.00517.63
8.1.40.0040.00417.63
8.1.30.0000.00817.76
8.1.20.0080.00017.75
8.1.10.0080.00017.69
8.1.00.0030.00617.53
8.0.300.0040.00418.77
8.0.290.0040.00416.73
8.0.280.0070.00018.55
8.0.270.0030.00317.35
8.0.260.0030.00317.37
8.0.250.0030.00317.13
8.0.240.0050.00317.02
8.0.230.0040.00416.99
8.0.220.0070.00016.96
8.0.210.0000.00717.03
8.0.200.0060.00017.05
8.0.190.0030.00517.14
8.0.180.0040.00417.11
8.0.170.0040.00417.09
8.0.160.0070.00016.96
8.0.150.0040.00416.90
8.0.140.0000.00717.02
8.0.130.0060.00013.58
8.0.120.0020.00516.91
8.0.110.0040.00416.98
8.0.100.0040.00417.18
8.0.90.0000.00816.93
8.0.80.0100.00716.95
8.0.70.0040.00417.11
8.0.60.0000.00717.08
8.0.50.0070.00016.95
8.0.30.0130.00917.18
8.0.20.0060.01617.40
8.0.10.0020.00517.16
8.0.00.0030.01417.12
7.4.330.0030.00315.11
7.4.320.0000.00716.57
7.4.300.0030.00316.51
7.4.290.0040.00416.75
7.4.280.0000.00816.59
7.4.270.0000.00716.57
7.4.260.0000.00716.58
7.4.250.0040.00416.50
7.4.240.0040.00416.74
7.4.230.0070.00016.50
7.4.220.0140.00716.66
7.4.210.0000.02016.69
7.4.200.0000.00716.69
7.4.160.0140.00816.66
7.4.150.0080.01217.40
7.4.140.0160.00617.86
7.4.130.0080.01316.69
7.4.120.0080.01016.62
7.4.110.0140.00716.73
7.4.100.0130.00616.57
7.4.90.0100.00716.55
7.4.80.0180.00619.39
7.4.70.0090.00916.34
7.4.60.0090.01516.57
7.4.50.0080.00016.58
7.4.40.0100.00716.66
7.4.30.0120.01216.51
7.4.00.0140.00514.80
7.3.330.0000.00513.36
7.3.320.0060.00013.50
7.3.310.0020.00516.56
7.3.300.0050.00316.44
7.3.290.0080.00716.55
7.3.280.0070.01116.48
7.3.270.0200.00017.40
7.3.260.0060.01216.64
7.3.250.0070.01216.66
7.3.240.0120.00916.51
7.3.230.0060.01316.60
7.3.210.0100.00716.77
7.3.200.0110.01519.39
7.3.190.0080.01216.55
7.3.180.0070.01016.50
7.3.170.0050.01816.68
7.3.160.0180.00516.61
7.3.120.0000.01715.19
7.3.110.0080.01215.08
7.3.100.0100.00615.23
7.3.90.0100.00614.91
7.3.80.0060.00914.66
7.3.70.0060.01214.95
7.3.60.0080.00814.81
7.3.50.0030.01414.91
7.3.40.0140.00014.91
7.3.30.0030.00615.04
7.3.20.0060.00916.45
7.3.10.0050.00816.67
7.3.00.0080.00716.54
7.2.330.0100.01016.88
7.2.320.0080.01416.83
7.2.310.0140.00316.71
7.2.300.0130.00516.74
7.2.290.0080.01116.67
7.2.250.0000.02115.23
7.2.240.0070.01414.93
7.2.230.0100.01015.16
7.2.220.0070.01115.16
7.2.210.0070.01014.81
7.2.200.0080.00515.06
7.2.190.0070.00415.34
7.2.180.0090.00915.13
7.2.170.0030.01015.17
7.2.130.0060.00916.38
7.2.120.0090.00916.82
7.2.110.0040.00916.75
7.2.100.0030.01217.07
7.2.90.0070.01316.68
7.2.80.0240.01016.32
7.2.70.0190.00316.95
7.2.60.0050.01216.84
7.2.50.0150.00316.61
7.2.40.0100.01016.83
7.2.30.0100.00716.79
7.2.20.0070.01016.50
7.2.10.0100.00716.61
7.2.00.0080.00718.27
7.1.330.0030.01315.84
7.1.320.0110.00015.95
7.1.310.0130.00615.77
7.1.300.0040.00415.73
7.1.290.0090.00615.71
7.1.280.0000.01115.73
7.1.270.0040.01115.64
7.1.260.0030.01415.74
7.1.250.0050.01015.77
7.1.200.0050.00515.96
7.1.100.0000.01218.00
7.1.70.0040.00717.38
7.1.60.0100.01319.32
7.1.50.0160.00617.21
7.1.00.0000.08022.28
7.0.200.0040.00416.79
7.0.140.0000.07021.97
7.0.60.0070.08020.07
7.0.50.0000.04717.89
7.0.40.0030.04320.13
7.0.30.0470.04020.33
7.0.20.0370.07020.10
7.0.10.0030.05020.09
7.0.00.0100.04020.05
5.6.280.0030.07721.16
5.6.210.0130.07720.60
5.6.200.0030.04318.19
5.6.190.0030.04320.77
5.6.180.0100.06020.77
5.6.170.0370.06020.47
5.6.160.0130.07020.43
5.6.150.0100.08018.22
5.6.140.0100.05318.15
5.6.130.0000.05718.25
5.6.120.0030.04321.18
5.6.110.0000.09021.17
5.6.100.0070.09021.11
5.6.90.0100.09020.91
5.6.80.0070.07320.44
5.6.70.4100.04020.54
5.5.350.0370.07020.36
5.5.340.0070.08018.09
5.5.330.0100.08020.25
5.5.320.0300.08020.24
5.5.310.0370.04320.34
5.5.300.0070.08017.93
5.5.290.0030.07717.95
5.5.280.0070.08320.69
5.5.270.0030.08720.88
5.5.260.0070.08720.66
5.5.250.0130.08320.71
5.5.240.4100.03720.07
5.4.450.0730.07019.31
5.4.440.0630.06019.61
5.4.430.0570.07019.47
5.4.420.0830.04719.58
5.4.410.0500.05019.31
5.4.400.0930.05319.02
5.4.390.0070.08019.28
5.4.380.0830.05319.29
5.4.370.0600.05719.06
5.4.360.0670.06719.29
5.4.350.0770.06019.30
5.4.340.0080.05312.05
5.4.320.0080.03712.54
5.4.310.0080.04612.54
5.4.300.0090.04212.55
5.4.290.0070.04812.54
5.4.280.0030.05212.44
5.4.270.0080.04512.44
5.4.260.0080.04012.44
5.4.250.0060.04812.44
5.4.240.0090.04212.44
5.4.230.0070.04112.43
5.4.220.0060.04212.43
5.4.210.0070.03612.43
5.4.200.0090.03612.43
5.4.190.0080.03612.43
5.4.180.0100.03412.43
5.4.170.0020.04612.43
5.4.160.0070.03712.43
5.4.150.0090.03412.43
5.4.140.0090.03612.11
5.4.130.0100.03212.10
5.4.120.0050.03912.05
5.4.110.0100.04312.05
5.4.100.0040.03712.05
5.4.90.0110.03312.05
5.4.80.0050.04012.05
5.4.70.0100.03812.04
5.4.60.0060.03712.05
5.4.50.0110.04312.05
5.4.40.0060.03712.04
5.4.30.0050.04012.04
5.4.20.0070.05212.04
5.4.10.0100.03512.03
5.4.00.0090.03911.52
5.3.290.0080.04112.80
5.3.280.0050.04112.71
5.3.270.0080.04312.73
5.3.260.0070.04912.72
5.3.250.0120.06412.72
5.3.240.0170.06512.72
5.3.230.0110.06812.71
5.3.220.0170.09612.68
5.3.210.0070.05612.68
5.3.200.0140.09012.68
5.3.190.0120.06312.68
5.3.180.0080.05012.67
5.3.170.0090.04912.67
5.3.160.0120.03712.67
5.3.150.0130.06912.68
5.3.140.0100.05112.66
5.3.130.0130.05612.66
5.3.120.0070.04512.65
5.3.110.0070.04112.66
5.3.100.0040.03912.13
5.3.90.0110.03612.11
5.3.80.0070.03512.10
5.3.70.0040.03912.10
5.3.60.0060.03612.08
5.3.50.0060.03612.02
5.3.40.0030.04412.02
5.3.30.0110.04311.98
5.3.20.0080.03811.76
5.3.10.0060.03611.73
5.3.00.0110.03411.72
5.2.170.0050.0369.22
5.2.160.0050.0319.22
5.2.150.0080.0409.21
5.2.140.0040.0419.21
5.2.130.0060.0339.18
5.2.120.0070.0279.18
5.2.110.0030.0319.19
5.2.100.0020.0319.18
5.2.90.0040.0299.18
5.2.80.0050.0329.18
5.2.70.0060.0309.18
5.2.60.0050.0309.13
5.2.50.0060.0289.10
5.2.40.0120.0339.08
5.2.30.0100.0379.05
5.2.20.0060.0349.05
5.2.10.0040.0308.95
5.2.00.0060.0278.81
5.1.60.0070.0218.09
5.1.50.0060.0238.09
5.1.40.0060.0248.07
5.1.30.0040.0268.42
5.1.20.0050.0298.44
5.1.10.0120.0288.17
5.1.00.0060.0248.17
5.0.50.0050.0226.64
5.0.40.0050.0216.51
5.0.30.0070.0296.32
5.0.20.0060.0186.28
5.0.10.0070.0226.27
5.0.00.0060.0366.25
4.4.90.0070.0184.78
4.4.80.0070.0194.75
4.4.70.0030.0234.76
4.4.60.0030.0154.76
4.4.50.0000.0194.77
4.4.40.0030.0254.71
4.4.30.0050.0154.76
4.4.20.0030.0164.84
4.4.10.0030.0164.85
4.4.00.0040.0264.76
4.3.110.0030.0204.67
4.3.100.0040.0164.67
4.3.90.0040.0144.64
4.3.80.0050.0234.58
4.3.70.0020.0194.63
4.3.60.0060.0184.63
4.3.50.0060.0154.63
4.3.40.0040.0224.54
4.3.30.0020.0173.30
4.3.20.0010.0173.28
4.3.10.0030.0183.24
4.3.00.0100.0238.13

preferences:
41.69 ms | 401 KiB | 5 Q