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]; for($i = 0; $i < strlen($message); $i++) { if(!in_array(hexdec(bin2hex(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.0160.00618.36
8.3.50.0110.00721.11
8.3.40.0090.00918.78
8.3.30.0070.00719.20
8.3.20.0070.00020.34
8.3.10.0000.00823.48
8.3.00.0080.00019.30
8.2.180.0030.01217.00
8.2.170.0070.00722.96
8.2.160.0070.00720.35
8.2.150.0040.00424.18
8.2.140.0000.00924.66
8.2.130.0040.00426.16
8.2.120.0040.00422.00
8.2.110.0030.00722.21
8.2.100.0120.00017.63
8.2.90.0030.00519.21
8.2.80.0040.00417.97
8.2.70.0000.01117.63
8.2.60.0050.00517.93
8.2.50.0030.00618.07
8.2.40.0030.00519.88
8.2.30.0040.00418.09
8.2.20.0040.00417.66
8.2.10.0000.00718.15
8.2.00.0000.00917.77
8.1.280.0110.00425.92
8.1.270.0040.00422.05
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.85
8.1.230.0040.00718.98
8.1.220.0000.00817.74
8.1.210.0000.00918.77
8.1.200.0000.00917.22
8.1.190.0080.00017.23
8.1.180.0000.00918.10
8.1.170.0060.00618.56
8.1.160.0050.00322.04
8.1.150.0070.00018.85
8.1.140.0040.00417.41
8.1.130.0030.00317.80
8.1.120.0040.00417.55
8.1.110.0040.00417.55
8.1.100.0040.00417.48
8.1.90.0000.00717.53
8.1.80.0040.00417.52
8.1.70.0000.00717.49
8.1.60.0000.00817.66
8.1.50.0040.00417.54
8.1.40.0040.00417.57
8.1.30.0090.00017.57
8.1.20.0000.00817.70
8.1.10.0000.00817.57
8.1.00.0040.00417.49
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0030.00318.49
8.0.270.0030.00317.21
8.0.260.0050.00317.21
8.0.250.0000.00717.08
8.0.240.0050.00217.08
8.0.230.0000.00716.98
8.0.220.0070.00016.95
8.0.210.0070.00017.01
8.0.200.0000.00616.96
8.0.190.0040.00416.95
8.0.180.0000.00717.07
8.0.170.0060.00316.87
8.0.160.0000.00717.04
8.0.150.0040.00416.79
8.0.140.0040.00416.99
8.0.130.0000.00613.38
8.0.120.0000.00816.94
8.0.110.0000.00716.89
8.0.100.0000.00717.02
8.0.90.0040.00416.89
8.0.80.0120.00417.00
8.0.70.0000.00816.86
8.0.60.0000.00717.05
8.0.50.0070.00016.92
8.0.30.0080.01117.21
8.0.20.0160.00817.46
8.0.10.0050.00216.91
8.0.00.0070.01016.83
7.4.330.0030.00315.09
7.4.320.0030.00316.60
7.4.300.0000.00616.52
7.4.290.0070.00016.57
7.4.280.0040.00416.53
7.4.270.0000.00716.58
7.4.260.0030.00616.60
7.4.250.0060.00316.38
7.4.240.0000.00716.58
7.4.230.0040.00416.59
7.4.220.0160.01016.59
7.4.210.0100.00716.54
7.4.200.0000.00716.40
7.4.160.0110.00616.40
7.4.150.0150.00617.40
7.4.140.0140.00517.86
7.4.130.0130.00416.56
7.4.120.0070.01016.50
7.4.110.0100.00716.46
7.4.100.0070.01316.54
7.4.90.0070.01816.59
7.4.80.0110.00719.39
7.4.70.0100.01016.51
7.4.60.0090.00916.62
7.4.50.0030.00516.50
7.4.40.0000.01716.51
7.4.30.0130.00616.30
7.4.00.0060.00614.94
7.3.330.0030.00313.27
7.3.320.0030.00313.33
7.3.310.0070.00016.35
7.3.300.0070.00016.45
7.3.290.0080.00816.46
7.3.280.0080.01116.47
7.3.270.0080.01217.40
7.3.260.0000.01916.44
7.3.250.0170.00316.63
7.3.240.0180.00416.44
7.3.230.0060.01216.49
7.3.210.0060.01516.46
7.3.200.0090.01619.39
7.3.190.0000.01916.38
7.3.180.0100.00716.71
7.3.170.0160.00616.54
7.3.160.0080.00816.66
7.2.330.0070.01116.63
7.2.320.0080.01016.73
7.2.310.0110.00716.82
7.2.300.0110.00716.80
7.2.290.0090.01216.81
7.2.60.0070.01016.96
7.2.00.0060.00619.24
7.1.200.0130.00015.76
7.1.100.0030.00718.24
7.1.70.0040.00717.19
7.1.60.0030.02219.19
7.1.50.0130.01317.00
7.1.00.0030.07722.43
7.0.200.0060.00316.64
7.0.140.0130.06322.12
7.0.110.0070.05019.98
7.0.100.0030.03719.88
7.0.90.0070.08020.00
7.0.80.0230.04019.96
7.0.70.0000.04319.97
7.0.60.0200.05319.99
7.0.50.0100.04319.91
7.0.40.0000.04719.64
7.0.30.0030.04019.72
7.0.20.0100.06719.73
7.0.10.0170.07019.78
7.0.00.0100.08019.84
5.6.280.0030.07321.15
5.6.260.0100.06020.92
5.6.250.0100.08020.63
5.6.240.0030.09020.67
5.6.230.0100.08320.55
5.6.220.0030.04020.57
5.6.210.0030.04320.63
5.6.200.0100.06320.66
5.6.190.0170.03320.85
5.6.180.0070.04020.59
5.6.170.0070.04020.66
5.6.160.0170.08020.67
5.6.150.0000.07720.57
5.6.140.0170.06720.72
5.6.130.0100.07020.66
5.6.120.0070.09320.87
5.6.110.0100.07320.63
5.6.100.0130.07020.61
5.6.90.0100.07020.63
5.6.80.0100.07020.02
5.6.70.0100.06720.04
5.6.60.0030.04320.04
5.6.50.0130.05319.94
5.6.40.0130.07319.91
5.6.30.0100.07320.02
5.6.20.0030.03720.03
5.6.10.0070.07720.05
5.6.00.0070.07320.02
5.5.380.0030.04017.65
5.5.370.0070.03017.73
5.5.360.0000.04717.54
5.5.350.0030.04017.55
5.5.340.0000.04318.08
5.5.330.0000.04318.22
5.5.320.0030.04317.93
5.5.310.0000.07318.13
5.5.300.0070.08317.91
5.5.290.0170.07718.07
5.5.280.0000.03718.09
5.5.270.0070.03317.92
5.5.260.0030.08717.91
5.5.250.0030.09017.91
5.5.240.0030.08317.33
5.5.230.0100.04717.48
5.5.220.0130.06717.29
5.5.210.0000.04017.45
5.5.200.0170.04717.59
5.5.190.0100.08017.59
5.5.180.0100.07317.49
5.5.160.0000.07017.57
5.5.150.0070.07017.61
5.5.140.0100.02717.27
5.5.130.0030.08017.26
5.5.120.0100.06717.45
5.5.110.0070.07717.60
5.5.100.0100.07317.35
5.5.90.0100.06317.18
5.5.80.0100.06317.35
5.5.70.0030.03317.21
5.5.60.0030.07717.46
5.5.50.0100.07017.37
5.5.40.0030.03717.34
5.5.30.0070.03017.31
5.5.20.0000.08317.34
5.5.10.0030.06317.18
5.5.00.0070.07017.06
5.4.450.0100.07319.38
5.4.440.0070.08319.31
5.4.430.0030.07019.41
5.4.420.0070.07319.32
5.4.410.0070.08019.21
5.4.400.0070.06019.04
5.4.390.0030.07018.95
5.4.380.0070.05318.95
5.4.370.0000.04318.96
5.4.360.0030.07719.01
5.4.350.0030.07019.23
5.4.340.0070.03019.14
5.4.320.0070.08319.14
5.4.310.0100.02719.24
5.4.300.0100.07319.00
5.4.290.0100.07019.33
5.4.280.0100.07719.00
5.4.270.0070.07718.98
5.4.260.0100.05319.24
5.4.250.0070.06718.98
5.4.240.0030.07318.94
5.4.230.0000.07718.99
5.4.220.0070.08018.95
5.4.210.0100.06018.98
5.4.200.0130.06018.96
5.4.190.0100.06718.94
5.4.180.0100.02719.23
5.4.170.0130.06719.17
5.4.160.0070.07319.00
5.4.150.0030.03319.17
5.4.140.0130.02316.41
5.4.130.0000.03316.52
5.4.120.0070.02716.48
5.4.110.0030.04316.30
5.4.100.0100.07316.39
5.4.90.0000.03316.56
5.4.80.0030.06316.32
5.4.70.0000.03316.40
5.4.60.0100.07016.45
5.4.50.0100.04716.64
5.4.40.0030.03716.53
5.4.30.0070.03716.53
5.4.20.0030.03716.39
5.4.10.0070.05016.35
5.4.00.0070.03715.83
5.3.290.0030.03314.68
5.3.280.0170.02314.63
5.3.270.0070.03014.59
5.3.260.0070.07314.60
5.3.250.0070.06714.63
5.3.240.0030.07314.59
5.3.230.0030.07314.59
5.3.220.0070.05314.43
5.3.210.0030.03314.53
5.3.200.0070.03714.61
5.3.190.0070.07714.55
5.3.180.0070.06714.60
5.3.170.0000.08314.58
5.3.160.0070.07014.54
5.3.150.0070.03014.53
5.3.140.0100.05314.66
5.3.130.0000.04314.63
5.3.120.0070.07314.53
5.3.110.0170.06014.64
5.3.100.0030.03314.18
5.3.90.0000.05014.25
5.3.80.0030.03013.99
5.3.70.0130.05714.10
5.3.60.0030.07714.13
5.3.50.0030.07713.93
5.3.40.0030.03013.79
5.3.30.0000.03313.94
5.3.20.0070.06313.71
5.3.10.0100.02313.66
5.3.00.0170.06313.63
5.2.170.0070.05011.76
5.2.160.0070.05311.76
5.2.150.0000.02711.76
5.2.140.0000.03311.76
5.2.130.0030.02311.76
5.2.120.0030.06311.76
5.2.110.0070.06711.76
5.2.100.0070.05711.76
5.2.90.0070.02011.76
5.2.80.0100.05711.76
5.2.70.0070.06011.76
5.2.60.0000.03311.76
5.2.50.0030.02711.76
5.2.40.0070.04311.76
5.2.30.0000.03311.76
5.2.20.0100.04711.76
5.2.10.0070.04011.76
5.2.00.0000.03011.76
5.1.60.0030.03311.76
5.1.50.0070.04011.76
5.1.40.0030.04711.76
5.1.30.0070.03711.76
5.1.20.0030.05311.76
5.1.10.0000.04311.76
5.1.00.0000.05711.76
5.0.50.0030.02711.76
5.0.40.0070.01011.76
5.0.30.0030.05711.76
5.0.20.0000.02311.76
5.0.10.0000.02311.76
5.0.00.0030.03011.76
4.4.90.0000.01311.76
4.4.80.0100.02711.76
4.4.70.0030.03311.76
4.4.60.0000.03311.76
4.4.50.0000.01311.76
4.4.40.0070.01711.76
4.4.30.0000.04011.76
4.4.20.0000.01711.76
4.4.10.0070.03311.76
4.4.00.0000.03011.76
4.3.110.0030.03311.76
4.3.100.0000.01711.76
4.3.90.0030.01311.76
4.3.80.0000.02311.76
4.3.70.0000.01711.76
4.3.60.0000.02711.76
4.3.50.0000.01311.76
4.3.40.0000.05711.76
4.3.30.0070.03011.76
4.3.20.0000.03011.76
4.3.10.0000.03311.76
4.3.00.0070.03011.76

preferences:
34.94 ms | 401 KiB | 5 Q