3v4l.org

run code in 300+ PHP versions simultaneously
<?php function unicode2utf8($c){ $output=""; if($c < 0x80) { return chr($c); } else if($c < 0x800) { return chr( 0xc0 | ($c >> 6) ).chr( 0x80 | ($c & 0x3f) ); } else if($c < 0x10000) { return chr( 0xe0 | ($c >> 12) ).chr( 0x80 | (($c >> 6) & 0x3f) ).chr( 0x80 | ($c & 0x3f) ); } else if($c < 0x200000) { return chr(0xf0 | ($c >> 18)).chr(0x80 | (($c >> 12) & 0x3f)).chr(0x80 | (($c >> 6) & 0x3f)).chr(0x80 | ($c & 0x3f)); } return false; } function sanitizeFileName( $name ) { $invalidCharacters = array("\x2f", "\x22", "\x2a", "\x3a", "\x3c", "\x3e", "\x3f", "\x5c", "\x7f"); $name = str_replace($invalidCharacters, '', $name); $name = preg_replace('/[\x{0000}-\x{001F}]/u', '', $name); var_dump('1 '.$name); $name = preg_replace('/[\x{0080}-\x{009F}]/u', '', $name); var_dump('2 '.$name); $name = preg_replace('/[\x{E000}-\x{F8FF}]/u', '', $name); var_dump('3 '.$name); $name = preg_replace('/[\x{FDD0}-\x{FDEF}]/u', '', $name); var_dump('4 '.$name); $name = preg_replace('/[\x{FFF0}-\x{FFFF}]/u', '', $name); var_dump('5 '.$name); return $name; } $str = "blablabla ǹéñ~#>< - ".unicode2utf8(0xE001).' - '.unicode2utf8(0xFDD3).' - '.unicode2utf8(0xFD00); var_dump($str); var_dump(sanitizeFileName($str));

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.0110.01116.88
8.3.50.0080.01022.06
8.3.40.0040.01118.92
8.3.30.0180.00319.02
8.3.20.0080.00020.16
8.3.10.0040.00423.48
8.3.00.0080.00020.70
8.2.180.0040.01116.46
8.2.170.0040.01122.96
8.2.160.0070.00722.23
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00422.33
8.2.110.0090.00019.24
8.2.100.0060.00617.91
8.2.90.0050.00319.22
8.2.80.0080.00017.97
8.2.70.0040.00417.75
8.2.60.0040.00418.05
8.2.50.0000.00818.07
8.2.40.0040.00419.34
8.2.30.0000.00818.13
8.2.20.0080.00017.87
8.2.10.0050.00319.74
8.2.00.0040.00417.88
8.1.280.0110.00425.92
8.1.270.0060.00323.92
8.1.260.0080.00026.35
8.1.250.0030.00528.09
8.1.240.0060.00319.66
8.1.230.0070.00319.03
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0100.00017.60
8.1.190.0050.00317.52
8.1.180.0040.00418.10
8.1.170.0060.00318.89
8.1.160.0050.00321.99
8.1.150.0000.00718.85
8.1.140.0040.00417.61
8.1.130.0030.00317.93
8.1.120.0000.00717.61
8.1.110.0050.00317.65
8.1.100.0000.00717.61
8.1.90.0030.00617.64
8.1.80.0000.00717.69
8.1.70.0000.00717.56
8.1.60.0040.00417.77
8.1.50.0030.00617.75
8.1.40.0000.00917.70
8.1.30.0040.00417.75
8.1.20.0040.00417.85
8.1.10.0080.00017.59
8.1.00.0080.00017.66
8.0.300.0040.00418.77
8.0.290.0050.00317.30
8.0.280.0000.00718.57
8.0.270.0000.00717.37
8.0.260.0000.00816.98
8.0.250.0000.00617.13
8.0.240.0100.00017.18
8.0.230.0040.00417.23
8.0.220.0030.00317.14
8.0.210.0030.00317.16
8.0.200.0000.00617.23
8.0.190.0040.00417.12
8.0.180.0050.00317.18
8.0.170.0040.00417.16
8.0.160.0000.00817.15
8.0.150.0030.00517.16
8.0.140.0000.00717.09
8.0.130.0000.00513.62
8.0.120.0000.00817.03
8.0.110.0080.00017.12
8.0.100.0040.00417.01
8.0.90.0070.00317.06
8.0.80.0070.01117.10
8.0.70.0030.00517.17
8.0.60.0060.00317.02
8.0.50.0000.00717.01
8.0.30.0120.00717.31
8.0.20.0120.00617.48
8.0.10.0080.00017.13
8.0.00.0060.01316.91
7.4.330.0050.00015.03
7.4.320.0030.00316.90
7.4.300.0000.00616.75
7.4.290.0030.00316.77
7.4.280.0030.00316.84
7.4.270.0030.00316.77
7.4.260.0050.00216.82
7.4.250.0050.00216.81
7.4.240.0020.00516.88
7.4.230.0030.00316.95
7.4.220.0120.00617.02
7.4.210.0070.00916.79
7.4.200.0080.00016.82
7.4.190.0040.00417.00
7.4.160.0110.00417.00
7.4.150.0160.01317.40
7.4.140.0130.00517.86
7.4.130.0120.00816.65
7.4.120.0110.00916.92
7.4.110.0040.01216.58
7.4.100.0120.00616.66
7.4.90.0070.01116.65
7.4.80.0100.00716.74
7.4.70.0090.00916.94
7.4.60.0110.00716.74
7.4.50.0000.00816.62
7.4.40.0070.01322.77
7.4.30.0100.01016.62
7.4.00.0090.00615.30
7.3.330.0000.00613.54
7.3.320.0030.00313.52
7.3.310.0030.00316.39
7.3.300.0030.00316.40
7.3.290.0090.00616.46
7.3.280.0110.00716.54
7.3.270.0070.01117.40
7.3.260.0110.00616.59
7.3.250.0050.01616.68
7.3.240.0100.01316.72
7.3.230.0150.00316.43
7.3.210.0090.00916.45
7.3.200.0100.01319.39
7.3.190.0130.00616.66
7.3.180.0090.00616.67
7.3.170.0110.00716.66
7.3.160.0110.00616.75
7.3.120.0040.00814.82
7.2.330.0040.01416.82
7.2.320.0030.01516.90
7.2.310.0090.00916.93
7.2.300.0070.01016.79
7.2.290.0110.00516.86
7.1.70.0030.00517.48
7.1.60.0070.01819.29
7.1.50.0030.01716.96
7.1.00.0030.07722.29
7.0.200.0080.00416.79
7.0.140.0030.07322.04
7.0.100.0170.04720.04
7.0.90.0200.06019.97
7.0.80.0030.09019.98
7.0.70.0170.04020.00
7.0.60.0170.07020.06
7.0.50.0130.06320.30
7.0.40.0030.05320.02
7.0.30.0130.06720.11
7.0.20.0100.05320.13
7.0.10.0030.08720.06
7.0.00.0070.07320.05
5.6.280.0000.07321.01
5.6.250.0070.07020.83
5.6.240.0130.07020.63
5.6.230.0100.07720.55
5.6.220.0100.06720.75
5.6.210.0100.08320.63
5.6.200.0070.09721.07
5.6.190.0100.07721.06
5.6.180.0070.05020.96
5.6.170.0130.07321.04
5.6.160.0070.07721.05
5.6.150.0030.08321.05
5.6.140.0100.08321.08
5.6.130.0030.08321.15
5.6.120.0030.09021.06
5.6.110.0130.06021.14
5.6.100.0100.04721.02
5.6.90.0100.08321.17
5.6.80.0170.06720.50
5.6.70.0130.07720.33
5.6.60.0030.08320.44
5.6.50.0130.07320.54
5.6.40.0100.08020.43
5.6.30.0100.07320.32
5.6.20.0100.07720.45
5.6.10.0170.06320.42
5.6.00.0030.08320.43
5.5.380.0000.08720.37
5.5.370.0100.08020.38
5.5.360.0100.07720.43
5.5.350.0100.04020.41
5.5.340.0070.04720.92
5.5.330.0000.08320.85
5.5.320.0130.07320.82
5.5.310.0170.06320.66
5.5.300.0100.07720.91
5.5.290.0200.06320.89
5.5.280.0030.06020.92
5.5.270.0070.09020.87
5.5.260.0070.07720.92
5.5.250.0170.07020.63
5.5.240.0130.07720.29
5.5.230.0100.06020.27
5.5.220.0070.08320.23
5.5.210.0070.08320.23
5.5.200.0100.07720.14
5.5.190.0200.06720.27
5.5.180.0100.07720.24
5.5.160.0100.07320.29
5.5.150.0030.07720.11
5.5.140.0100.04320.19
5.5.130.0100.07720.25
5.5.120.0070.08020.19
5.5.110.0130.07320.25
5.5.100.0030.05320.09
5.5.90.0070.04720.17
5.5.80.0200.06720.07
5.5.70.0100.07320.19
5.5.60.0070.07320.02
5.5.50.0070.07720.13
5.5.40.0070.05020.07
5.5.30.0130.06320.18
5.5.20.0030.07720.07
5.5.10.0070.08019.98
5.5.00.0100.08020.02
5.4.450.0070.03719.54
5.4.440.0030.08319.46
5.4.430.0030.08319.39
5.4.420.0070.07719.36
5.4.410.0030.08719.23
5.4.400.0200.07319.10
5.4.390.0030.08018.88
5.4.380.0070.07718.85
5.4.370.0030.08019.02
5.4.360.0070.07719.14
5.4.350.0130.06719.05
5.4.340.0130.07019.18
5.4.320.0070.08019.03
5.4.310.0130.07319.19
5.4.300.0100.07319.05
5.4.290.0170.05319.18
5.4.280.0000.08318.87
5.4.270.0100.07319.02
5.4.260.0070.08318.84
5.4.250.0070.07718.84
5.4.240.0070.07719.21
5.4.230.0100.06019.15
5.4.220.0030.08319.02
5.4.210.0030.04719.16
5.4.200.0070.07019.18
5.4.190.0130.03719.03
5.4.180.0070.07319.08
5.4.170.0070.06319.17
5.4.160.0030.06019.08
5.4.150.0130.07019.10
5.4.140.0030.07316.39
5.4.130.0030.07316.43
5.4.120.0100.07316.51
5.4.110.0130.06316.52
5.4.100.0070.04016.38
5.4.90.0100.04716.52
5.4.80.0070.04316.43
5.4.70.0000.04016.42
5.4.60.0070.03316.49
5.4.50.0030.04016.40
5.4.40.0070.03316.38
5.4.30.0070.03316.44
5.4.20.0070.04716.49
5.4.10.0070.05716.33
5.4.00.0030.04315.87
5.3.290.0070.08314.76
5.3.280.0030.04714.73
5.3.270.0130.06714.57
5.3.260.0030.08014.61
5.3.250.0170.06714.69
5.3.240.0170.06714.72
5.3.230.0100.06714.70
5.3.220.0070.05714.59
5.3.210.0030.08314.65
5.3.200.0100.05014.54
5.3.190.0100.05314.52
5.3.180.0030.03714.70
5.3.170.0000.04014.70
5.3.160.0070.04014.57
5.3.150.0000.04014.57
5.3.140.0070.03714.60
5.3.130.0030.04714.59
5.3.120.0000.04014.59
5.3.110.0000.04714.55
5.3.100.0030.03713.99
5.3.90.0070.06014.03
5.3.80.0000.07714.05
5.3.70.0000.04014.07
5.3.60.0030.06014.16
5.3.50.0070.03013.90
5.3.40.0030.05714.09
5.3.30.0070.05013.92
5.3.20.0030.03313.85
5.3.10.0000.03713.77
5.3.00.0030.04713.64
5.2.170.0000.03011.07
5.2.160.0070.02311.08
5.2.150.0030.02711.23
5.2.140.0000.03711.30
5.2.130.0030.06311.19
5.2.120.0030.04711.24
5.2.110.0030.03011.14
5.2.100.0070.02711.15
5.2.90.0000.04011.18
5.2.80.0070.05311.18
5.2.70.0070.05011.03
5.2.60.0000.03011.11
5.2.50.0070.03310.96
5.2.40.0030.02311.09
5.2.30.0030.04711.11
5.2.20.0000.04311.02
5.2.10.0100.01710.99
5.2.00.0000.03010.62
5.1.60.0000.02710.02
5.1.50.0030.02710.13
5.1.40.0000.0279.99
5.1.30.0070.03710.48
5.1.20.0000.02710.41
5.1.10.0000.03010.17
5.1.00.0000.02710.09
5.0.50.0030.0209.82
5.0.40.0030.0179.82
5.0.30.0000.0309.82
5.0.20.0070.0139.82
5.0.10.0000.0309.82
5.0.00.0030.0479.82
4.4.90.0000.0179.82
4.4.80.0000.0209.82
4.4.70.0000.0179.82
4.4.60.0030.0209.82
4.4.50.0070.0239.82
4.4.40.0000.0239.82
4.4.30.0000.0179.82
4.4.20.0000.0179.82
4.4.10.0000.0179.82
4.4.00.0000.0479.82
4.3.110.0000.0179.82
4.3.100.0000.0179.82
4.3.90.0000.0139.82
4.3.80.0000.0239.82
4.3.70.0030.0139.82
4.3.60.0000.0209.82
4.3.50.0000.0179.82
4.3.40.0000.0279.82
4.3.30.0000.0179.82
4.3.20.0000.0179.82
4.3.10.0030.0139.82
4.3.00.0030.0139.82

preferences:
41.17 ms | 401 KiB | 5 Q