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.60.0040.01118.43
8.3.50.0130.00522.14
8.3.40.0120.00618.79
8.3.30.0040.01119.21
8.3.20.0040.00420.21
8.3.10.0040.00423.66
8.3.00.0040.00419.50
8.2.180.0140.00316.63
8.2.170.0070.00722.96
8.2.160.0140.00020.50
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0050.00322.06
8.2.110.0000.01020.52
8.2.100.0080.00418.04
8.2.90.0000.00918.16
8.2.80.0060.00317.97
8.2.70.0080.00317.49
8.2.60.0040.00418.16
8.2.50.0060.00318.07
8.2.40.0000.00918.09
8.2.30.0040.00418.16
8.2.20.0030.00617.85
8.2.10.0000.00918.13
8.2.00.0050.00317.89
8.1.280.0000.01825.92
8.1.270.0030.00622.01
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0030.00622.25
8.1.230.0040.00720.85
8.1.220.0000.00817.79
8.1.210.0060.00318.85
8.1.200.0070.00417.25
8.1.190.0030.00717.35
8.1.180.0030.00618.10
8.1.170.0050.00418.59
8.1.160.0040.00422.13
8.1.150.0040.00419.00
8.1.140.0040.00417.63
8.1.130.0000.00717.93
8.1.120.0030.00517.56
8.1.110.0040.00417.57
8.1.100.0000.00817.59
8.1.90.0000.00817.58
8.1.80.0040.00417.46
8.1.70.0050.00217.52
8.1.60.0000.00917.71
8.1.50.0030.00617.51
8.1.40.0030.00517.61
8.1.30.0000.00917.74
8.1.20.0030.00517.70
8.1.10.0040.00417.67
8.1.00.0040.00417.61
8.0.300.0000.00820.25
8.0.290.0050.00317.00
8.0.280.0050.00218.61
8.0.270.0000.00817.24
8.0.260.0000.00717.36
8.0.250.0040.00417.00
8.0.240.0030.00517.06
8.0.230.0040.00417.13
8.0.220.0040.00417.11
8.0.210.0000.00717.02
8.0.200.0030.00317.03
8.0.190.0000.00817.11
8.0.180.0050.00317.05
8.0.170.0040.00416.97
8.0.160.0050.00216.94
8.0.150.0040.00416.99
8.0.140.0030.00516.91
8.0.130.0030.00313.50
8.0.120.0070.00317.02
8.0.110.0040.00416.95
8.0.100.0040.00416.88
8.0.90.0000.00817.07
8.0.80.0030.01317.13
8.0.70.0040.00417.13
8.0.60.0050.00217.09
8.0.50.0040.00417.10
8.0.30.0140.00817.26
8.0.20.0160.00417.40
8.0.10.0050.00316.93
8.0.00.0090.01016.68
7.4.330.0030.00315.09
7.4.320.0000.00716.70
7.4.300.0070.00016.71
7.4.290.0030.00516.62
7.4.280.0040.00416.61
7.4.270.0070.00016.62
7.4.260.0030.00516.70
7.4.250.0080.00016.67
7.4.240.0000.00716.59
7.4.230.0040.00416.50
7.4.220.0060.01516.71
7.4.210.0130.00916.63
7.4.200.0040.00416.73
7.4.160.0130.00716.64
7.4.150.0130.00917.40
7.4.140.0090.01217.86
7.4.130.0110.00716.65
7.4.120.0070.01216.59
7.4.110.0070.01116.52
7.4.100.0080.01216.60
7.4.90.0110.00816.46
7.4.80.0130.00619.39
7.4.70.0090.00916.57
7.4.60.0110.00816.55
7.4.50.0060.00316.84
7.4.40.0090.00916.32
7.4.30.0070.01016.73
7.4.10.0090.00915.04
7.4.00.0060.01114.76
7.3.330.0000.00513.40
7.3.320.0000.00613.52
7.3.310.0000.00716.36
7.3.300.0030.00516.43
7.3.290.0060.01016.54
7.3.280.0100.00716.50
7.3.270.0110.01117.40
7.3.260.0130.00816.41
7.3.250.0090.01416.55
7.3.240.0100.01316.49
7.3.230.0150.00616.44
7.3.210.0090.00916.69
7.3.200.0060.01619.39
7.3.190.0030.01516.71
7.3.180.0100.00716.60
7.3.170.0080.01216.45
7.3.160.0100.00716.49
7.3.130.0070.01115.03
7.3.120.0100.00714.71
7.3.110.0100.01014.86
7.3.100.0030.00915.03
7.3.90.0040.01115.05
7.3.80.0060.00314.91
7.3.70.0030.01314.92
7.3.60.0060.01214.64
7.3.50.0060.00915.13
7.3.40.0000.01014.96
7.3.30.0030.01214.77
7.3.20.0110.00616.82
7.3.10.0040.01216.56
7.3.00.0040.01616.77
7.2.330.0090.00916.52
7.2.320.0090.00916.72
7.2.310.0140.00316.84
7.2.300.0120.00616.59
7.2.290.0090.01516.75
7.2.260.0060.01315.17
7.2.250.0070.01115.17
7.2.240.0030.01315.26
7.2.230.0040.00814.93
7.2.220.0030.01615.00
7.2.210.0090.00315.05
7.2.200.0030.01015.30
7.2.190.0060.00915.07
7.2.180.0120.00615.27
7.2.170.0040.00714.91
7.2.160.0030.00615.12
7.2.150.0050.00517.06
7.2.140.0070.00716.66
7.2.130.0070.00716.97
7.2.120.0030.00616.75
7.2.110.0030.00916.91
7.2.100.0070.00317.00
7.2.90.0060.00916.82
7.2.80.0060.00616.98
7.2.70.0030.01016.70
7.2.60.0060.01116.70
7.2.50.0070.00316.79
7.2.40.0080.00817.08
7.2.30.0000.01417.16
7.2.20.0080.00817.13
7.2.10.0030.00916.98
7.2.00.0000.01718.16
7.1.330.0060.00916.02
7.1.320.0080.00815.61
7.1.310.0080.00815.98
7.1.300.0040.01215.61
7.1.290.0030.00715.79
7.1.280.0000.01615.91
7.1.270.0030.00615.87
7.1.260.0070.01015.82
7.1.250.0000.01315.71
7.1.240.0030.01015.93
7.1.230.0120.00315.85
7.1.220.0060.00615.64
7.1.210.0060.00615.99
7.1.200.0060.00815.87
7.1.190.0070.00715.77
7.1.180.0150.00015.86
7.1.170.0060.00616.03
7.1.160.0040.00715.83
7.1.150.0000.01215.57
7.1.140.0090.00315.79
7.1.130.0040.01115.67
7.1.120.0030.01215.85
7.1.110.0090.00615.67
7.1.100.0080.00717.16
7.1.90.0000.01316.08
7.1.80.0050.00515.85
7.1.70.0100.00216.53
7.1.60.0100.01017.48
7.1.50.0060.01016.54
7.1.40.0000.01115.95
7.1.30.0030.01315.89
7.1.20.0060.00615.89
7.1.10.0030.01715.72
7.1.00.0060.04119.22
7.0.330.0030.01015.41
7.0.320.0070.01015.42
7.0.310.0000.01715.49
7.0.300.0090.00315.55
7.0.290.0090.00615.45
7.0.280.0090.00615.68
7.0.270.0030.00915.42
7.0.260.0040.00715.35
7.0.250.0030.01415.39
7.0.240.0040.00415.25
7.0.230.0000.01715.53
7.0.220.0060.01015.46
7.0.210.0090.00615.60
7.0.200.0040.00616.03
7.0.190.0080.00815.52
7.0.180.0070.00715.24
7.0.170.0060.01015.36
7.0.160.0030.01015.25
7.0.150.0000.01415.42
7.0.140.0080.03818.76
7.0.130.0080.00315.45
7.0.120.0050.00515.27
7.0.110.0040.00715.54
7.0.100.0000.01215.53
7.0.90.0090.00615.43
7.0.80.0030.01015.35
7.0.70.0030.00715.51
7.0.60.0040.03217.69
7.0.50.0030.02716.78
7.0.40.0080.02316.73
7.0.30.0220.04517.00
7.0.20.0120.04916.82
7.0.10.0100.04516.72
7.0.00.0070.03116.74
5.6.400.0060.01214.65
5.6.390.0040.00814.31
5.6.380.0000.01914.97
5.6.370.0000.01414.61
5.6.360.0060.00614.57
5.6.350.0090.00614.74
5.6.340.0070.01014.47
5.6.330.0030.01214.23
5.6.320.0000.01414.50
5.6.310.0100.00714.86
5.6.300.0040.00714.32
5.6.290.0070.01014.61
5.6.280.0060.03817.89
5.6.270.0070.00714.45
5.6.260.0030.01014.35
5.6.250.0090.00614.67
5.6.240.0090.00614.48
5.6.230.0060.00814.48
5.6.220.0000.01314.60
5.6.210.0030.04317.40
5.6.200.0080.03216.24
5.6.190.0060.02317.52
5.6.180.0030.03017.61
5.6.170.0220.03917.64
5.6.160.0020.03217.51
5.6.150.0040.03016.31
5.6.140.0090.04416.30
5.6.130.0010.03316.35
5.6.120.0050.02217.76
5.6.110.0090.04217.78
5.6.100.0080.02817.66
5.6.90.0100.04217.74
5.6.80.0070.03617.39
5.6.70.2280.02217.52
5.6.60.0000.01114.43
5.6.50.0100.00314.49
5.6.40.0060.00614.41
5.6.30.0070.01114.35
5.6.20.0100.00714.32
5.6.10.0040.00814.47
5.6.00.0080.00314.47
5.5.380.0060.00914.50
5.5.370.0030.01314.33
5.5.360.0070.00714.49
5.5.350.0120.03417.43
5.5.340.0060.04216.17
5.5.330.0060.04417.42
5.5.320.0250.03517.44
5.5.310.0130.04417.39
5.5.300.0100.04116.28
5.5.290.0030.02716.18
5.5.280.0050.02517.70
5.5.270.0070.03317.72
5.5.260.0050.04717.57
5.5.250.0130.03817.50
5.5.240.1290.02217.46
5.5.230.0030.00714.41
5.5.220.0030.01214.64
5.5.210.0000.01314.25
5.5.200.0030.01214.37
5.5.190.0000.01014.78
5.5.180.0030.01014.25
5.5.170.0040.00814.40
5.5.160.0090.00314.66
5.5.150.0000.01514.34
5.5.140.0100.00014.58
5.5.130.0000.01014.28
5.5.120.0070.01014.50
5.5.110.0120.00314.46
5.5.100.0030.01014.60
5.5.90.0060.01014.11
5.5.80.0040.01214.72
5.5.70.0110.00414.23
5.5.60.0070.01014.54
5.5.50.0070.01014.23
5.5.40.0000.01114.52
5.5.30.0070.01014.23
5.5.20.0080.00414.66
5.5.10.0070.00714.48
5.5.00.0030.01414.42
5.4.450.0430.03715.29
5.4.440.0430.03315.45
5.4.430.0450.03015.24
5.4.420.0350.03315.42
5.4.410.0370.02815.38
5.4.400.0500.03015.28
5.4.390.0400.03115.12
5.4.380.0280.03715.22
5.4.370.0210.03814.98
5.4.360.0500.03214.91
5.4.350.0540.03214.94
5.4.340.0030.02711.75
5.4.330.0130.00011.20
5.4.320.0070.02611.85
5.4.310.0040.02511.89
5.4.300.0030.02811.88
5.4.290.0050.02811.83
5.4.280.0100.02511.77
5.4.270.0050.02911.59
5.4.260.0080.02711.82
5.4.250.0060.02911.74
5.4.240.0060.02811.69
5.4.230.0040.02811.71
5.4.220.0030.02711.81
5.4.210.0120.02511.93
5.4.200.0070.02811.72
5.4.190.0050.03311.67
5.4.180.0070.02711.90
5.4.170.0070.02611.78
5.4.160.0060.02211.63
5.4.150.0050.03011.89
5.4.140.0030.03011.71
5.4.130.0100.02311.57
5.4.120.0060.02311.61
5.4.110.0010.03011.54
5.4.100.0040.02411.63
5.4.90.0070.02511.71
5.4.80.0060.02811.56
5.4.70.0060.02111.40
5.4.60.0040.02411.54
5.4.50.0090.02111.67
5.4.40.0080.02511.52
5.4.30.0070.02811.67
5.4.20.0040.02511.55
5.4.10.0020.02611.60
5.4.00.0040.02511.22
5.3.290.0130.04512.80
5.3.280.0150.04612.71
5.3.270.0060.04512.72
5.3.260.0100.04912.71
5.3.250.0070.04212.72
5.3.240.0100.04912.72
5.3.230.0110.04512.71
5.3.220.0110.05012.68
5.3.210.0140.05312.68
5.3.200.0130.04812.68
5.3.190.0090.05312.68
5.3.180.0080.05212.68
5.3.170.0090.05112.67
5.3.160.0050.05512.67
5.3.150.0080.05212.67
5.3.140.0150.05012.66
5.3.130.0130.05012.66
5.3.120.0090.05212.66
5.3.110.0110.05112.66
5.3.100.0130.04612.13
5.3.90.0060.05412.11
5.3.80.0090.04612.10
5.3.70.0070.04812.09
5.3.60.0080.04612.08
5.3.50.0120.03812.02
5.3.40.0090.04412.02
5.3.30.0070.04111.98
5.3.20.0050.03711.77
5.3.10.0040.03611.73
5.3.00.0060.03811.72
5.2.170.0050.0439.22
5.2.160.0050.0319.23
5.2.150.0060.0309.22
5.2.140.0050.0319.21
5.2.130.0030.0329.18
5.2.120.0050.0289.18
5.2.110.0040.0299.19
5.2.100.0050.0289.18
5.2.90.0050.0309.19
5.2.80.0040.0319.18
5.2.70.0090.0269.18
5.2.60.0050.0299.13
5.2.50.0050.0319.10
5.2.40.0040.0299.08
5.2.30.0050.0309.05
5.2.20.0070.0269.05
5.2.10.0010.0328.95
5.2.00.0040.0308.81
5.1.60.0040.0248.09
5.1.50.0060.0238.09
5.1.40.0020.0268.07
5.1.30.0070.0238.43
5.1.20.0050.0268.44
5.1.10.0080.0318.17
5.1.00.0070.0228.17
5.0.50.0050.0196.65
5.0.40.0030.0206.51
5.0.30.0020.0326.32
5.0.20.0060.0166.29
5.0.10.0030.0206.27
5.0.00.0000.0336.25
4.4.90.0050.0144.78
4.4.80.0030.0164.75
4.4.70.0040.0144.76
4.4.60.0050.0144.76
4.4.50.0020.0184.77
4.4.40.0010.0314.71
4.4.30.0030.0154.76
4.4.20.0020.0164.85
4.4.10.0040.0144.85
4.4.00.0040.0244.76
4.3.110.0050.0184.67
4.3.100.0030.0154.67
4.3.90.0030.0154.64
4.3.80.0030.0264.59
4.3.70.0010.0174.63
4.3.60.0050.0154.63
4.3.50.0030.0154.63
4.3.40.0030.0244.54
4.3.30.0010.0173.30
4.3.20.0050.0153.28
4.3.10.0000.0173.25
4.3.00.0170.0208.11

preferences:
55.1 ms | 401 KiB | 5 Q