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++; } } $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.0150.00618.43
8.3.50.0120.00621.28
8.3.40.0120.00918.93
8.3.30.0040.01119.09
8.3.20.0040.00419.93
8.3.10.0030.00623.71
8.3.00.0000.00919.38
8.2.180.0060.01518.14
8.2.170.0120.00322.96
8.2.160.0110.01120.52
8.2.150.0030.00524.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0070.00022.23
8.2.110.0110.01122.28
8.2.100.0040.00817.75
8.2.90.0000.00819.05
8.2.80.0040.00417.97
8.2.70.0000.00917.75
8.2.60.0000.00819.73
8.2.50.0070.00319.33
8.2.40.0060.00319.95
8.2.30.0040.00418.10
8.2.20.0050.00317.84
8.2.10.0030.00618.22
8.2.00.0050.00317.82
8.1.280.0040.01125.92
8.1.270.0040.00422.20
8.1.260.0030.00526.35
8.1.250.0050.00228.09
8.1.240.0090.00023.98
8.1.230.0040.00719.10
8.1.220.0040.00417.77
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0040.00417.22
8.1.180.0000.00818.10
8.1.170.0130.00918.32
8.1.160.0000.00722.02
8.1.150.0040.00418.92
8.1.140.0070.00017.47
8.1.130.0030.00317.86
8.1.120.0000.00717.49
8.1.110.0000.00717.48
8.1.100.0040.00417.41
8.1.90.0040.00417.36
8.1.80.0000.00817.49
8.1.70.0080.00017.48
8.1.60.0060.00317.62
8.1.50.0030.00617.45
8.1.40.0060.00317.68
8.1.30.0030.00517.75
8.1.20.0000.00817.72
8.1.10.0040.00417.64
8.1.00.0000.00817.55
8.0.300.0080.00018.77
8.0.290.0040.00416.88
8.0.280.0040.00418.42
8.0.270.0000.00717.30
8.0.260.0030.00317.36
8.0.250.0030.00317.09
8.0.240.0030.00617.13
8.0.230.0040.00417.17
8.0.220.0040.00416.95
8.0.210.0040.00416.89
8.0.200.0030.00317.10
8.0.190.0000.00817.00
8.0.180.0020.00516.96
8.0.170.0030.00617.04
8.0.160.0000.00817.00
8.0.150.0000.00717.08
8.0.140.0040.00416.90
8.0.130.0000.00613.44
8.0.120.0000.00917.05
8.0.110.0040.00417.04
8.0.100.0000.00817.06
8.0.90.0050.00216.91
8.0.80.0110.00817.11
8.0.70.0030.00516.97
8.0.60.0050.00317.12
8.0.50.0050.00316.88
8.0.30.0110.00817.26
8.0.20.0110.00817.42
8.0.10.0040.00417.13
8.0.00.0070.01116.81
7.4.330.0050.00015.11
7.4.320.0070.00016.61
7.4.300.0030.00316.52
7.4.290.0020.00516.49
7.4.280.0080.00016.59
7.4.270.0000.00716.62
7.4.260.0000.00716.48
7.4.250.0060.00316.48
7.4.240.0050.00216.49
7.4.230.0050.00216.35
7.4.220.0100.01016.65
7.4.210.0060.01016.54
7.4.200.0040.00416.63
7.4.160.0140.00316.45
7.4.150.0130.00717.40
7.4.140.0080.01317.86
7.4.130.0090.00916.57
7.4.120.0090.00916.56
7.4.110.0040.01516.44
7.4.100.0110.00716.51
7.4.90.0060.01916.41
7.4.80.0130.00619.39
7.4.70.0080.01516.53
7.4.60.0060.01216.54
7.4.50.0060.00316.20
7.4.40.0210.00316.43
7.4.30.0130.00616.41
7.4.10.0100.00915.72
7.4.00.0080.00915.26
7.3.330.0000.00613.45
7.3.320.0000.00613.45
7.3.310.0080.00016.41
7.3.300.0030.00316.41
7.3.290.0090.00816.42
7.3.280.0060.01016.46
7.3.270.0170.00317.40
7.3.260.0160.00416.34
7.3.250.0120.00816.40
7.3.240.0110.01116.52
7.3.230.0110.00816.52
7.3.210.0000.01916.44
7.3.200.0140.01119.39
7.3.190.0070.01416.43
7.3.180.0110.00716.44
7.3.170.0060.01216.53
7.3.160.0130.01016.51
7.3.130.0130.00315.78
7.3.120.0080.01015.41
7.3.110.0090.00915.38
7.3.100.0040.01115.43
7.3.90.0050.01215.60
7.3.80.0040.01115.54
7.3.70.0100.00615.38
7.3.60.0030.01215.43
7.3.50.0070.00815.46
7.3.40.0070.00715.36
7.3.30.0040.01315.35
7.3.20.0070.00917.28
7.3.10.0060.00917.12
7.3.00.0090.00517.14
7.2.330.0110.00816.66
7.2.320.0060.01316.75
7.2.310.0220.00016.66
7.2.300.0100.01616.66
7.2.290.0100.01316.70
7.2.260.0120.00815.79
7.2.250.0080.01015.62
7.2.240.0090.00915.70
7.2.230.0070.00815.59
7.2.220.0070.01115.56
7.2.210.0070.01015.58
7.2.200.0070.00815.54
7.2.190.0050.00715.45
7.2.180.0050.00915.56
7.2.170.0040.01215.47
7.2.160.0050.00915.63
7.2.150.0060.00817.40
7.2.140.0080.00517.45
7.2.130.0090.00617.46
7.2.120.0060.00817.47
7.2.110.0070.01017.43
7.2.100.0020.01417.43
7.2.90.0090.00717.36
7.2.80.0090.00717.34
7.2.70.0100.00717.49
7.2.60.0060.00817.21
7.2.50.0070.00517.30
7.2.40.0100.00617.38
7.2.30.0070.01117.41
7.2.20.0020.01117.36
7.2.10.0070.00817.32
7.2.00.0050.01017.53
7.1.330.0020.01316.49
7.1.320.0110.00216.19
7.1.310.0060.01116.23
7.1.300.0030.01016.39
7.1.290.0050.00916.32
7.1.280.0080.00916.24
7.1.270.0060.00816.36
7.1.260.0080.00416.25
7.1.250.0060.00816.34
7.1.240.0060.00916.26
7.1.230.0020.01116.29
7.1.220.0100.00316.29
7.1.210.0050.00716.24
7.1.200.0100.00316.24
7.1.190.0070.00416.30
7.1.180.0100.00316.40
7.1.170.0050.00816.31
7.1.160.0040.00916.24
7.1.150.0040.01016.40
7.1.140.0060.00716.35
7.1.130.0050.01016.29
7.1.120.0020.01216.29
7.1.110.0040.01116.39
7.1.100.0070.00616.31
7.1.90.0060.00816.39
7.1.80.0040.00916.36
7.1.70.0060.00616.56
7.1.60.0080.01016.99
7.1.50.0080.00716.50
7.1.40.0040.01116.24
7.1.30.0050.00816.37
7.1.20.0070.00716.30
7.1.10.0080.00616.42
7.1.00.0070.02217.70
7.0.330.0060.00715.97
7.0.320.0060.00715.94
7.0.310.0050.00915.93
7.0.300.0060.00815.85
7.0.290.0050.00615.94
7.0.280.0070.00516.01
7.0.270.0050.00715.87
7.0.260.0060.00715.94
7.0.250.0070.00916.05
7.0.240.0060.00816.02
7.0.230.0060.00916.09
7.0.220.0080.00515.96
7.0.210.0050.00715.95
7.0.200.0040.00716.15
7.0.190.0050.00815.90
7.0.180.0040.01016.00
7.0.170.0060.00416.00
7.0.160.0070.00515.93
7.0.150.0070.00816.00
7.0.140.0080.02217.53
7.0.130.0070.00616.01
7.0.120.0070.00716.04
7.0.110.0050.00716.00
7.0.100.0070.00815.94
7.0.90.0030.00716.00
7.0.80.0080.00615.98
7.0.70.0070.00715.88
7.0.60.0060.02516.96
7.0.50.0050.02516.45
7.0.40.0060.01815.45
7.0.30.0130.01615.62
7.0.20.0070.03015.50
7.0.10.0060.02815.47
7.0.00.0040.01615.58
5.6.400.0050.00915.07
5.6.390.0030.01115.07
5.6.380.0070.00815.05
5.6.370.0080.00714.94
5.6.360.0070.00514.99
5.6.350.0090.00614.81
5.6.340.0040.01214.96
5.6.330.0080.00814.69
5.6.320.0040.01014.78
5.6.310.0030.00915.11
5.6.300.0060.00715.09
5.6.290.0040.00814.99
5.6.280.0030.02616.47
5.6.270.0050.01014.95
5.6.260.0050.00815.09
5.6.250.0040.01015.05
5.6.240.0050.00814.94
5.6.230.0100.00414.99
5.6.220.0070.00614.95
5.6.210.0080.01716.35
5.6.200.0060.02915.76
5.6.190.0050.02816.39
5.6.180.0070.02616.20
5.6.170.0180.02316.32
5.6.160.0060.02616.42
5.6.150.0070.02515.63
5.6.140.0050.01615.64
5.6.130.0040.02915.74
5.6.120.0040.02016.40
5.6.110.0030.03116.39
5.6.100.0070.02416.38
5.6.90.0080.02316.47
5.6.80.0110.02016.30
5.6.70.1310.01616.13
5.6.60.0060.01014.77
5.6.50.0060.01014.90
5.6.40.0090.00814.82
5.6.30.0060.00914.73
5.6.20.0050.01014.60
5.6.10.0080.00914.85
5.6.00.0050.01014.82
5.5.380.0040.01114.81
5.5.370.0060.01114.73
5.5.360.0040.01314.77
5.5.350.0120.01716.23
5.5.340.0070.02715.62
5.5.330.0060.01616.30
5.5.320.0140.02516.37
5.5.310.0090.01816.42
5.5.300.0070.02615.73
5.5.290.0080.02315.75
5.5.280.0070.02916.32
5.5.270.0060.03016.36
5.5.260.0040.03116.36
5.5.250.0060.02016.24
5.5.240.0990.02016.07
5.5.230.0080.00814.81
5.5.220.0040.01014.78
5.5.210.0060.01014.74
5.5.200.0090.00614.76
5.5.190.0080.00914.89
5.5.180.0030.01314.94
5.5.170.0090.00914.91
5.5.160.0070.01114.85
5.5.150.0050.01214.73
5.5.140.0090.00914.85
5.5.130.0090.00714.86
5.5.120.0060.00914.68
5.5.110.0050.01014.72
5.5.100.0020.01414.88
5.5.90.0050.01114.74
5.5.80.0070.01014.73
5.5.70.0050.01214.75
5.5.60.0100.00514.75
5.5.50.0090.00914.78
5.5.40.0050.00914.84
5.5.30.0070.00814.98
5.5.20.0070.00714.77
5.5.10.0050.01014.83
5.5.00.0070.00814.85
5.4.450.0140.02214.47
5.4.440.0180.02014.47
5.4.430.0210.02014.46
5.4.420.0110.02214.46
5.4.410.0230.01814.48
5.4.400.0230.02014.33
5.4.390.0270.01614.35
5.4.380.0190.02214.36
5.4.370.0060.01814.35
5.4.360.0230.02014.28
5.4.350.0190.01814.41
5.4.340.0040.01412.60
5.4.330.0040.00512.77
5.4.320.0070.01212.71
5.4.310.0050.01712.66
5.4.300.0070.02012.67
5.4.290.0070.01512.74
5.4.280.0050.01912.67
5.4.270.0060.01512.66
5.4.260.0040.01912.63
5.4.250.0050.01812.71
5.4.240.0060.01612.67
5.4.230.0060.02612.65
5.4.220.0020.02012.70
5.4.210.0040.01612.67
5.4.200.0030.01912.65
5.4.190.0060.01912.73
5.4.180.0040.01912.69
5.4.170.0040.01912.67
5.4.160.0040.01512.62
5.4.150.0040.01512.69
5.4.140.0050.01812.57
5.4.130.0050.02112.61
5.4.120.0090.02012.64
5.4.110.0060.03012.61
5.4.100.0060.01612.56
5.4.90.0040.01712.61
5.4.80.0050.01812.55
5.4.70.0060.01612.66
5.4.60.0050.01412.59
5.4.50.0040.01312.59
5.4.40.0050.01512.59
5.4.30.0030.01912.55
5.4.20.0070.01612.62
5.4.10.0040.01912.60
5.4.00.0050.01612.46
5.3.290.0060.04512.80
5.3.280.0080.05612.71
5.3.270.0130.05212.72
5.3.260.0120.04612.72
5.3.250.0080.04712.71
5.3.240.0060.05012.72
5.3.230.0040.04512.71
5.3.220.0080.04312.68
5.3.210.0050.04712.68
5.3.200.0120.04712.68
5.3.190.0120.04712.68
5.3.180.0140.05212.67
5.3.170.0090.05012.67
5.3.160.0120.04612.68
5.3.150.0070.06512.68
5.3.140.0100.07012.66
5.3.130.0100.04512.66
5.3.120.0100.04112.66
5.3.110.0100.04512.66
5.3.100.0070.05312.13
5.3.90.0090.03612.11
5.3.80.0100.06412.09
5.3.70.0090.04612.09
5.3.60.0080.04612.08
5.3.50.0060.04612.02
5.3.40.0060.04812.02
5.3.30.0110.04611.98
5.3.20.0090.04511.77
5.3.10.0060.04811.73
5.3.00.0060.04711.72
5.2.170.0050.0429.22
5.2.160.0040.0429.22
5.2.150.0040.0349.22
5.2.140.0050.0319.21
5.2.130.0040.0309.17
5.2.120.0040.0309.18
5.2.110.0080.0259.19
5.2.100.0080.0259.18
5.2.90.0050.0299.18
5.2.80.0030.0329.17
5.2.70.0060.0319.17
5.2.60.0040.0349.13
5.2.50.0050.0359.09
5.2.40.0070.0289.07
5.2.30.0030.0329.05
5.2.20.0070.0289.04
5.2.10.0050.0288.95
5.2.00.0030.0348.81
5.1.60.0030.0268.09
5.1.50.0070.0228.08
5.1.40.0050.0258.07
5.1.30.0040.0278.42
5.1.20.0040.0298.45
5.1.10.0050.0268.16
5.1.00.0070.0258.17
5.0.50.0040.0236.64
5.0.40.0040.0196.50
5.0.30.0030.0336.32
5.0.20.0040.0286.29
5.0.10.0050.0196.27
5.0.00.0050.0306.25
4.4.90.0030.0184.78
4.4.80.0030.0164.75
4.4.70.0020.0174.75
4.4.60.0020.0174.75
4.4.50.0050.0174.77
4.4.40.0030.0254.71
4.4.30.0020.0164.76
4.4.20.0010.0174.84
4.4.10.0030.0214.85
4.4.00.0040.0314.76
4.3.110.0050.0204.67
4.3.100.0040.0144.66
4.3.90.0040.0224.63
4.3.80.0020.0254.59
4.3.70.0040.0174.63
4.3.60.0030.0164.63
4.3.50.0010.0184.63
4.3.40.0020.0264.54
4.3.30.0000.0183.30
4.3.20.0020.0173.28
4.3.10.0020.0163.24
4.3.00.0170.0237.07

preferences:
48.91 ms | 401 KiB | 5 Q