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('/[a-b]/', '', $name); var_dump('0 '.$name); $name = preg_replace('/[\x{0000}-\x{001F}]', '', $name); var_dump('1 '.$name); $name = preg_replace('/[\x{0080}-\x{009F}]', '', $name); var_dump('2 '.$name); $name = preg_replace('/[\x{E000}-\x{F8FF}]', '', $name); var_dump('3 '.$name); $name = preg_replace('/[\x{FDD0}-\x{FDEF}]', '', $name); var_dump('4 '.$name); $name = preg_replace('/[\x{FFF0}-\x{FFFF}]', '', $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.0090.00618.63
8.3.50.0110.00522.06
8.3.40.0150.00019.13
8.3.30.0040.01119.09
8.3.20.0060.00320.35
8.3.10.0000.00823.48
8.3.00.0060.00319.63
8.2.180.0040.01218.54
8.2.170.0110.00422.96
8.2.160.0070.01020.46
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0000.00822.38
8.2.110.0000.00822.33
8.2.100.0100.00017.97
8.2.90.0050.00319.27
8.2.80.0060.00317.97
8.2.70.0060.00317.88
8.2.60.0040.00418.05
8.2.50.0070.00418.07
8.2.40.0030.00519.95
8.2.30.0000.00818.20
8.2.20.0000.00917.82
8.2.10.0040.00418.29
8.2.00.0040.00418.00
8.1.280.0060.01225.92
8.1.270.0090.00024.01
8.1.260.0000.00926.35
8.1.250.0000.00728.09
8.1.240.0030.00623.96
8.1.230.0080.00419.13
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0060.00317.25
8.1.190.0050.00517.48
8.1.180.0030.00618.10
8.1.170.0040.00418.91
8.1.160.0050.00322.13
8.1.150.0040.00418.84
8.1.140.0050.00317.59
8.1.130.0030.00317.94
8.1.120.0000.00817.69
8.1.110.0040.00417.54
8.1.100.0050.00317.61
8.1.90.0000.00717.65
8.1.80.0000.00817.69
8.1.70.0050.00317.61
8.1.60.0030.00617.78
8.1.50.0040.00417.68
8.1.40.0040.00417.70
8.1.30.0060.00317.85
8.1.20.0000.00817.85
8.1.10.0000.00817.59
8.1.00.0000.00717.68
8.0.300.0050.00318.77
8.0.290.0060.00317.30
8.0.280.0080.00018.42
8.0.270.0050.00217.32
8.0.260.0070.00017.32
8.0.250.0040.00417.12
8.0.240.0070.00317.23
8.0.230.0050.00217.11
8.0.220.0050.00317.02
8.0.210.0040.00417.14
8.0.200.0000.00617.12
8.0.190.0000.00817.09
8.0.180.0070.00017.15
8.0.170.0030.00517.13
8.0.160.0040.00417.22
8.0.150.0040.00717.06
8.0.140.0000.00817.00
8.0.130.0060.00013.50
8.0.120.0000.00917.14
8.0.110.0020.00517.11
8.0.100.0030.00517.00
8.0.90.0070.00017.15
8.0.80.0130.01017.08
8.0.70.0040.00416.99
8.0.60.0070.00017.01
8.0.50.0000.00716.99
8.0.30.0150.00817.35
8.0.20.0120.00617.40
8.0.10.0000.00817.16
8.0.00.0090.00916.69
7.4.330.0050.00015.00
7.4.320.0060.00016.65
7.4.300.0030.00316.86
7.4.290.0030.00316.85
7.4.280.0000.00716.70
7.4.270.0080.00016.79
7.4.260.0070.00016.75
7.4.250.0080.00016.71
7.4.240.0050.00216.68
7.4.230.0040.00416.94
7.4.220.0000.02016.96
7.4.210.0110.00616.86
7.4.200.0040.00416.96
7.4.190.0030.00316.95
7.4.160.0080.00816.83
7.4.150.0070.01017.40
7.4.140.0170.00017.86
7.4.130.0050.01516.88
7.4.120.0120.00516.76
7.4.110.0170.00316.80
7.4.100.0090.00916.72
7.4.90.0090.00916.73
7.4.80.0060.01219.39
7.4.70.0140.01116.67
7.4.60.0060.00916.51
7.4.50.0030.00316.84
7.4.40.0060.01516.78
7.4.30.0060.00916.66
7.4.10.0040.01215.30
7.4.00.0120.00515.18
7.3.330.0070.00013.47
7.3.320.0060.00013.54
7.3.310.0000.00716.44
7.3.300.0000.00716.57
7.3.290.0060.01016.57
7.3.280.0110.00616.56
7.3.270.0070.01017.40
7.3.260.0060.01216.46
7.3.250.0140.00616.65
7.3.240.0110.00716.83
7.3.230.0090.01016.80
7.3.210.0150.00616.74
7.3.200.0140.01019.39
7.3.190.0070.01116.60
7.3.180.0130.00316.67
7.3.170.0040.02016.89
7.3.160.0130.00616.64
7.3.130.0060.00915.11
7.3.120.0050.01115.08
7.3.110.0070.01315.14
7.3.100.0030.01115.21
7.3.90.0060.01014.96
7.3.80.0030.00915.00
7.3.70.0100.00615.04
7.3.60.0090.01215.14
7.3.50.0000.01315.08
7.3.40.0060.00615.12
7.3.30.0030.00915.25
7.3.20.0030.00716.66
7.3.10.0070.00716.70
7.3.00.0060.00916.61
7.2.330.0090.00916.68
7.2.320.0110.00916.71
7.2.310.0120.00616.75
7.2.300.0100.00716.85
7.2.290.0110.00716.83
7.2.260.0100.00715.39
7.2.250.0090.00915.40
7.2.240.0000.01514.98
7.2.230.0030.01015.29
7.2.220.0090.00615.42
7.2.210.0110.00315.30
7.2.200.0190.00315.20
7.2.190.0030.01615.25
7.2.180.0040.01115.05
7.2.170.0110.00015.25
7.2.160.0100.00314.99
7.2.150.0060.00617.02
7.2.140.0040.00817.06
7.2.130.0070.00717.13
7.2.120.0000.01417.18
7.2.110.0100.00717.18
7.2.100.0030.00716.91
7.2.90.0070.01117.06
7.2.80.0090.00616.84
7.2.70.0100.01017.11
7.2.60.0030.00917.14
7.2.50.0110.00717.11
7.2.40.0080.01116.91
7.2.30.0070.00417.20
7.2.20.0040.01217.20
7.2.10.0040.01116.87
7.2.00.0060.00918.36
7.1.330.0040.01115.87
7.1.320.0120.00616.12
7.1.310.0060.00916.13
7.1.300.0060.00316.15
7.1.290.0070.00716.13
7.1.280.0040.01216.07
7.1.270.0060.00615.93
7.1.260.0080.00415.82
7.1.250.0130.00015.99
7.1.240.0030.01215.95
7.1.230.0070.00715.65
7.1.220.0040.00716.01
7.1.210.0070.00715.88
7.1.200.0000.01416.05
7.1.190.0030.00615.93
7.1.180.0030.01316.09
7.1.170.0030.00915.94
7.1.160.0110.00416.09
7.1.150.0030.01015.74
7.1.140.0090.00615.75
7.1.130.0080.00416.07
7.1.120.0100.00316.00
7.1.110.0030.00915.89
7.1.100.0040.00917.02
7.1.90.0070.00716.04
7.1.80.0030.00715.95
7.1.70.0070.00516.82
7.1.60.0110.00917.81
7.1.50.0080.00916.48
7.1.40.0040.00815.76
7.1.30.0040.01115.98
7.1.20.0030.00916.03
7.1.10.0090.00015.92
7.1.00.0060.03819.09
7.0.330.0040.01115.18
7.0.320.0000.00915.63
7.0.310.0130.00315.46
7.0.300.0030.00615.65
7.0.290.0110.00415.68
7.0.280.0040.00815.71
7.0.270.0090.00015.68
7.0.260.0030.00615.76
7.0.250.0070.00315.34
7.0.240.0040.00815.75
7.0.230.0040.00815.64
7.0.220.0000.00915.45
7.0.210.0060.00515.77
7.0.200.0030.00716.27
7.0.190.0060.00615.80
7.0.180.0040.00715.59
7.0.170.0110.00415.59
7.0.160.0050.00415.59
7.0.150.0040.01115.36
7.0.140.0050.03618.92
7.0.130.0000.00915.68
7.0.120.0060.00615.71
7.0.110.0030.01015.68
7.0.100.0030.00615.73
7.0.90.0100.00715.71
7.0.80.0060.00615.57
7.0.70.0030.00915.57
7.0.60.0020.04218.65
7.0.50.0050.02718.81
7.0.40.0030.03816.90
7.0.30.0050.04216.85
7.0.20.0070.04416.87
7.0.10.0110.04016.86
7.0.00.0030.02417.04
5.6.400.0080.00414.64
5.6.390.0040.01514.54
5.6.380.0030.01014.28
5.6.370.0130.00314.04
5.6.360.0030.00914.13
5.6.350.0040.01114.69
5.6.340.0030.01014.04
5.6.330.0060.00614.38
5.6.320.0030.01314.01
5.6.310.0050.00514.57
5.6.300.0070.00714.56
5.6.290.0000.00914.45
5.6.280.0050.03817.84
5.6.270.0030.00714.21
5.6.260.0060.00714.51
5.6.250.0070.00714.68
5.6.240.0030.00914.56
5.6.230.0070.01014.79
5.6.220.0040.01114.48
5.6.210.0000.04417.43
5.6.200.0050.02417.80
5.6.190.0050.02317.74
5.6.180.0050.04617.77
5.6.170.0030.04517.74
5.6.160.0030.04717.62
5.6.150.0080.03717.84
5.6.140.0050.04617.61
5.6.130.0030.04517.72
5.6.120.0020.04617.61
5.6.110.0080.04517.73
5.6.100.0080.04017.60
5.6.90.0080.04117.70
5.6.80.0080.03317.57
5.6.70.0050.04417.41
5.6.60.0070.04717.23
5.6.50.0020.04917.36
5.6.40.0050.03117.38
5.6.30.0050.02317.34
5.6.20.0070.03517.43
5.6.10.0020.04217.45
5.6.00.0040.03217.24
5.5.380.0060.00914.49
5.5.370.0060.00614.23
5.5.360.0040.00814.33
5.5.350.0090.03517.43
5.5.340.0070.04017.60
5.5.330.0050.02317.69
5.5.320.0070.04217.54
5.5.310.0030.04317.61
5.5.300.0100.03917.61
5.5.290.0050.04317.58
5.5.280.0050.04517.54
5.5.270.0090.03917.61
5.5.260.0030.03317.63
5.5.250.0030.04617.39
5.5.240.0050.03317.27
5.5.230.0050.03717.06
5.5.220.0140.03217.23
5.5.210.0090.03917.15
5.5.200.0030.04517.07
5.5.190.0030.03817.28
5.5.180.0070.04217.24
5.5.170.0110.00014.13
5.5.160.0100.03717.28
5.5.150.0150.03217.16
5.5.140.0030.04317.27
5.5.130.0040.04417.35
5.5.120.0030.04217.24
5.5.110.0030.04517.18
5.5.100.0090.03317.11
5.5.90.0030.03417.20
5.5.80.0050.04417.20
5.5.70.0070.04216.94
5.5.60.0040.04417.08
5.5.50.0080.03917.23
5.5.40.0020.04717.14
5.5.30.0030.03316.99
5.5.20.0040.04517.18
5.5.10.0080.03717.18
5.5.00.0050.04017.24
5.4.450.0020.04715.27
5.4.440.0030.04515.29
5.4.430.0000.04415.15
5.4.420.0060.02915.24
5.4.410.0040.03415.17
5.4.400.0060.02414.96
5.4.390.0100.03615.09
5.4.380.0050.03415.05
5.4.370.0080.03415.03
5.4.360.0050.04014.98
5.4.350.0020.02415.00
5.4.340.0020.03614.99
5.4.330.0000.00911.12
5.4.320.0030.02515.02
5.4.310.0040.03715.05
5.4.300.0020.04015.13
5.4.290.0020.04415.17
5.4.280.0060.03914.82
5.4.270.0050.03815.06
5.4.260.0030.03814.97
5.4.250.0050.04015.09
5.4.240.0050.03215.10
5.4.230.0070.03015.08
5.4.220.0040.03014.97
5.4.210.0020.04215.00
5.4.200.0080.03315.09
5.4.190.0060.03115.16
5.4.180.0030.04515.00
5.4.170.0060.04115.13
5.4.160.0020.03515.14
5.4.150.0120.03514.99
5.4.140.0010.04013.66
5.4.130.0060.03713.79
5.4.120.0030.04013.55
5.4.110.0020.02713.69
5.4.100.0050.03313.81
5.4.90.0070.03213.74
5.4.80.0030.03313.68
5.4.70.0070.03713.77
5.4.60.0090.03213.69
5.4.50.0030.04213.82
5.4.40.0040.03513.82
5.4.30.0000.04213.74
5.4.20.0020.03313.67
5.4.10.0020.04013.83
5.4.00.0040.03413.29
5.3.290.0040.03512.77
5.3.280.0070.02512.69
5.3.270.0030.04012.66
5.3.260.0020.03312.73
5.3.250.0000.04212.71
5.3.240.0020.04212.65
5.3.230.0070.03712.58
5.3.220.0030.03612.66
5.3.210.0020.04312.44
5.3.200.0030.04012.67
5.3.190.0000.04212.63
5.3.180.0020.04512.63
5.3.170.0030.03812.52
5.3.160.0020.04512.75
5.3.150.0030.04512.71
5.3.140.0050.03812.53
5.3.130.0100.03612.65
5.3.120.0030.03812.63
5.3.110.0070.03812.68
5.3.100.0010.04312.40
5.3.90.0050.04312.25
5.3.80.0030.03812.34
5.3.70.0060.03212.27
5.3.60.0000.04112.27
5.3.50.0080.03312.27
5.3.40.0040.03912.16
5.3.30.0000.02212.33
5.3.20.0020.02012.10
5.3.10.0020.02311.90
5.3.00.0060.01812.06
5.2.170.0070.05711.21
5.2.160.0030.06011.20
5.2.150.0000.05311.26
5.2.140.0000.03311.07
5.2.130.0030.02711.13
5.2.120.0030.02711.03
5.2.110.0000.02711.03
5.2.100.0030.02711.18
5.2.90.0000.03011.22
5.2.80.0000.03011.17
5.2.70.0000.03011.02
5.2.60.0000.02311.12
5.2.50.0000.03011.15
5.2.40.0000.02311.07
5.2.30.0030.02311.06
5.2.20.0000.02310.97
5.2.10.0030.02310.97
5.2.00.0030.03010.97
5.1.60.0030.02310.97
5.1.50.0000.03010.97
5.1.40.0000.02010.97
5.1.30.0000.02710.97
5.1.20.0030.02710.97
5.1.10.0000.02710.97
5.1.00.0000.02310.97
5.0.50.0000.01710.97
5.0.40.0030.01310.97
5.0.30.0000.02710.97
5.0.20.0030.01310.97
5.0.10.0000.01710.97
5.0.00.0000.04310.97
4.4.90.0000.01310.97
4.4.80.0030.01010.97
4.4.70.0030.01010.97
4.4.60.0030.01010.97
4.4.50.0030.01310.97
4.4.40.0030.02310.97
4.4.30.0030.01010.97
4.4.20.0000.02010.97
4.4.10.0030.01010.97
4.4.00.0000.02310.97
4.3.110.0000.01310.97
4.3.100.0030.01010.97
4.3.90.0000.01310.97
4.3.80.0000.02010.97
4.3.70.0000.01310.97
4.3.60.0000.01310.97
4.3.50.0000.01310.97
4.3.40.0000.02310.97
4.3.30.0000.01310.97
4.3.20.0000.01310.97
4.3.10.0000.01310.97
4.3.00.0030.01010.97

preferences:
37.89 ms | 401 KiB | 5 Q