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.0080.00816.75
8.3.50.0140.00317.54
8.3.40.0080.00819.03
8.3.30.0090.00618.87
8.3.20.0060.00318.91
8.3.10.0050.00518.90
8.3.00.0060.00319.50
8.2.180.0110.01117.00
8.2.170.0090.00622.96
8.2.160.0060.00919.26
8.2.150.0040.00424.18
8.2.140.0000.00924.66
8.2.130.0000.00726.16
8.2.120.0070.00021.12
8.2.110.0090.00019.28
8.2.100.0040.00817.84
8.2.90.0030.00619.47
8.2.80.0030.00519.28
8.2.70.0060.00317.63
8.2.60.0000.01017.93
8.2.50.0000.00818.07
8.2.40.0040.00418.16
8.2.30.0030.00518.18
8.2.20.0060.00317.82
8.2.10.0030.00617.93
8.2.00.0000.00718.03
8.1.280.0090.00625.92
8.1.270.0080.00023.99
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0060.00322.54
8.1.230.0040.00721.02
8.1.220.0040.00417.78
8.1.210.0030.00518.82
8.1.200.0090.00017.60
8.1.190.0030.00617.61
8.1.180.0000.00818.10
8.1.170.0040.00418.95
8.1.160.0050.00218.88
8.1.150.0000.00818.74
8.1.140.0000.00817.64
8.1.130.0030.00317.77
8.1.120.0070.00017.62
8.1.110.0030.00517.68
8.1.100.0080.00017.55
8.1.90.0040.00417.55
8.1.80.0030.00617.71
8.1.70.0000.00817.67
8.1.60.0040.00417.79
8.1.50.0030.00617.60
8.1.40.0030.00617.73
8.1.30.0060.00317.80
8.1.20.0000.00817.85
8.1.10.0080.00017.75
8.1.00.0030.00617.69
8.0.300.0040.00420.16
8.0.290.0040.00417.00
8.0.280.0000.00718.57
8.0.270.0000.00717.32
8.0.260.0050.00317.11
8.0.250.0050.00317.21
8.0.240.0050.00317.19
8.0.230.0030.00317.08
8.0.220.0070.00017.14
8.0.210.0030.00317.12
8.0.200.0030.00317.18
8.0.190.0000.00817.23
8.0.180.0040.00417.05
8.0.170.0040.00416.98
8.0.160.0000.00717.13
8.0.150.0050.00317.14
8.0.140.0070.00017.14
8.0.130.0050.00013.61
8.0.120.0000.00916.99
8.0.110.0040.00416.97
8.0.100.0080.00017.04
8.0.90.0000.00717.04
8.0.80.0100.01017.11
8.0.70.0000.00716.96
8.0.60.0040.00416.99
8.0.50.0040.00416.93
8.0.30.0150.00517.55
8.0.20.0120.00717.35
8.0.10.0000.01017.00
8.0.00.0130.00616.92
7.4.330.0020.00213.26
7.4.320.0060.00016.68
7.4.300.0030.00316.75
7.4.290.0000.00816.79
7.4.280.0040.00416.77
7.4.270.0030.00316.82
7.4.260.0000.00613.56
7.4.250.0090.00016.75
7.4.240.0030.00316.67
7.4.230.0040.00416.79
7.4.220.0070.01116.86
7.4.210.0120.00317.02
7.4.200.0030.00317.02
7.4.190.0030.00616.73
7.4.160.0130.00416.95
7.4.150.0130.00516.74
7.4.140.0090.00916.89
7.4.130.0090.00916.59
7.4.120.0060.01116.74
7.4.110.0070.01316.68
7.4.100.0070.01116.72
7.4.90.0120.01216.72
7.4.80.0030.01619.39
7.4.70.0110.00616.93
7.4.60.0090.00616.73
7.4.50.0080.00016.69
7.4.40.0120.00216.62
7.4.30.0070.01016.90
7.4.00.0090.00614.97
7.3.330.0000.00613.50
7.3.320.0060.00013.53
7.3.310.0050.00216.56
7.3.300.0030.00316.49
7.3.290.0050.01016.55
7.3.280.0100.00716.48
7.3.270.0110.00716.62
7.3.260.0090.00916.57
7.3.250.0150.00716.68
7.3.240.0140.00316.56
7.3.230.0060.01016.69
7.3.210.0090.00916.80
7.3.200.0060.01416.47
7.3.190.0110.00616.73
7.3.180.0110.01116.86
7.3.170.0080.00816.55
7.3.160.0060.01216.75
7.3.120.0060.00615.26
7.3.10.0180.00416.64
7.3.00.0100.01016.80
7.2.330.0120.00616.87
7.2.320.0040.01416.95
7.2.310.0130.01316.89
7.2.300.0100.00716.84
7.2.290.0070.01116.84
7.2.130.0120.00916.98
7.2.120.0080.01216.44
7.2.110.0130.00016.86
7.2.100.0140.00416.73
7.2.90.0100.00716.87
7.2.80.0130.00716.43
7.2.70.0090.00316.82
7.2.60.0080.00817.01
7.2.50.0080.00817.01
7.2.40.0030.01117.05
7.2.30.0110.00717.17
7.2.20.0120.00316.88
7.2.10.0150.00317.14
7.2.00.0060.00918.11
7.1.250.0080.00815.89
7.1.100.0030.00918.17
7.1.70.0000.00717.29
7.1.60.0040.01419.30
7.1.50.0030.01817.20
7.1.00.0000.07022.52
7.0.200.0090.00316.91
7.0.140.0000.07721.99
7.0.120.0000.06722.09
7.0.60.0030.08319.96
7.0.50.0070.04017.92
7.0.40.0000.04720.16
7.0.30.0430.05020.18
7.0.20.0330.07720.09
7.0.10.0070.08720.10
7.0.00.0030.08320.23
5.6.280.0070.06021.12
5.6.210.0070.03720.58
5.6.200.0100.08318.28
5.6.190.0100.07320.77
5.6.180.0370.06720.46
5.6.170.0170.06320.53
5.6.160.0130.05720.61
5.6.150.0070.08018.25
5.6.140.0230.05718.29
5.6.130.0100.06318.15
5.6.120.0170.08021.12
5.6.110.0030.08721.05
5.6.100.0130.07020.97
5.6.90.0130.07721.05
5.6.80.0100.07720.50
5.5.350.0070.06320.51
5.5.340.0070.06317.96
5.5.330.0100.08020.32
5.5.320.0100.07720.39
5.5.310.0200.05720.34
5.5.300.0200.04017.95
5.5.290.0000.07018.04
5.5.280.0030.04721.00
5.5.270.0170.07720.89
5.5.260.0100.08020.99
5.5.250.0030.05720.56
5.5.240.3100.03320.05
5.4.450.0030.07019.26
5.4.440.0030.07319.48
5.4.430.0070.07319.17
5.4.420.0070.04019.56
5.4.410.0030.04719.12
5.4.400.0070.04319.16
5.4.390.0000.07018.87
5.4.380.0070.06719.24
5.4.370.0030.07719.14
5.4.360.0070.05318.98
5.4.350.0070.04718.98
5.4.340.0030.04018.85
5.4.320.0000.04019.22
5.4.310.0070.03319.16
5.4.300.0130.04718.87
5.4.290.0170.03719.00
5.4.280.0030.04018.92
5.4.270.0030.03719.11
5.4.260.0000.04019.14
5.4.250.0070.03318.97
5.4.240.0100.03019.23
5.4.230.0000.04018.84
5.4.220.0100.03018.86
5.4.210.0070.03319.14
5.4.200.0070.03318.97
5.4.190.0030.03718.97
5.4.180.0070.03719.23
5.4.170.0030.03718.84
5.4.160.0000.04018.97
5.4.150.0030.03719.15
5.4.140.0070.03316.42
5.4.130.0070.03016.48
5.4.120.0030.03316.59
5.4.110.0100.05016.44
5.4.100.0070.07316.52
5.4.90.0070.04316.44
5.4.80.0030.05316.46
5.4.70.0000.07716.46
5.4.60.0000.07016.29
5.4.50.0130.07016.27
5.4.40.0030.07316.36
5.4.30.0100.07316.38
5.4.20.0070.03316.26
5.4.10.0100.05016.43
5.4.00.0030.07315.85
5.3.290.0030.03714.83
5.3.280.0100.03014.58
5.3.270.0030.03714.66
5.3.260.0000.04014.67
5.3.250.0070.03314.64
5.3.240.0030.03714.62
5.3.230.0070.03314.63
5.3.220.0070.03314.59
5.3.210.0000.04014.60
5.3.200.0030.07714.59
5.3.190.0100.05014.66
5.3.180.0030.06314.60
5.3.170.0030.06714.63
5.3.160.0070.07714.64
5.3.150.0070.04314.47
5.3.140.0070.07014.61
5.3.130.0100.07314.56
5.3.120.0100.04314.57
5.3.110.0070.04014.61
5.3.100.0030.06314.05
5.3.90.0030.04014.09
5.3.80.0130.06713.98
5.3.70.0070.07314.04
5.3.60.0030.03714.07
5.3.50.0130.06314.02
5.3.40.0070.07713.98
5.3.30.0070.07713.90
5.3.20.0100.05713.71
5.3.10.0100.04013.82
5.3.00.0030.03713.80
5.2.170.0030.06011.12
5.2.160.0030.05011.23
5.2.150.0030.06311.05
5.2.140.0070.04311.13
5.2.130.0030.05311.13
5.2.120.0030.03311.13
5.2.110.0000.03711.18
5.2.100.0000.04011.20
5.2.90.0000.04311.13
5.2.80.0030.06711.16
5.2.70.0030.05311.06
5.2.60.0070.05711.02
5.2.50.0030.04311.11
5.2.40.0030.06311.18
5.2.30.0030.05010.89
5.2.20.0070.05310.95
5.2.10.0070.02711.03
5.2.00.0070.06310.70
5.1.60.0070.0539.98
5.1.50.0070.04710.04
5.1.40.0130.0309.95
5.1.30.0070.04710.39
5.1.20.0070.04310.38
5.1.10.0030.06010.15
5.1.00.0030.02710.14
5.0.50.0000.0508.56
5.0.40.0000.0478.39
5.0.30.0030.0638.27
5.0.20.0000.0238.22
5.0.10.0030.0178.17
5.0.00.0000.0708.26
4.4.90.0070.0138.09
4.4.80.0000.0308.09
4.4.70.0000.0408.09
4.4.60.0030.0208.09
4.4.50.0030.0178.09
4.4.40.0000.0438.09
4.4.30.0030.0338.09
4.4.20.0070.0138.09
4.4.10.0030.0278.09
4.4.00.0000.0478.09
4.3.110.0070.0308.09
4.3.100.0100.0138.09
4.3.90.0030.0138.09
4.3.80.0030.0278.09
4.3.70.0000.0278.09
4.3.60.0000.0308.09
4.3.50.0070.0338.09
4.3.40.0030.0378.09
4.3.30.0100.0178.09
4.3.20.0000.0378.09
4.3.10.0000.0208.09
4.3.00.0000.0208.09

preferences:
45.5 ms | 401 KiB | 5 Q