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]/u', '', $name); var_dump('0 '.$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.0040.01116.75
8.3.50.0130.00722.01
8.3.40.0140.00418.84
8.3.30.0070.00719.05
8.3.20.0040.00420.39
8.3.10.0030.00623.36
8.3.00.0120.00019.26
8.2.180.0090.00618.47
8.2.170.0070.01122.96
8.2.160.0100.01020.26
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0160.00326.16
8.2.120.0080.00022.41
8.2.110.0030.00622.17
8.2.100.0110.00417.91
8.2.90.0000.00919.13
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0050.00317.93
8.2.50.0090.00018.07
8.2.40.0040.00418.16
8.2.30.0040.00418.07
8.2.20.0040.00417.93
8.2.10.0000.00817.94
8.2.00.0070.00018.06
8.1.280.0070.01025.92
8.1.270.0030.00624.02
8.1.260.0050.00326.35
8.1.250.0030.00528.09
8.1.240.0040.00423.82
8.1.230.0080.00319.27
8.1.220.0000.00817.91
8.1.210.0040.00418.77
8.1.200.0040.00717.47
8.1.190.0030.00517.66
8.1.180.0090.00018.10
8.1.170.0060.00618.58
8.1.160.0000.00822.07
8.1.150.0090.00018.84
8.1.140.0080.00017.52
8.1.130.0030.00317.94
8.1.120.0070.00017.50
8.1.110.0000.00817.57
8.1.100.0100.00017.64
8.1.90.0030.00517.66
8.1.80.0030.00617.56
8.1.70.0070.00017.55
8.1.60.0030.00717.81
8.1.50.0040.00417.61
8.1.40.0000.00817.76
8.1.30.0030.00617.78
8.1.20.0000.00917.71
8.1.10.0040.00417.73
8.1.00.0030.00617.50
8.0.300.0070.00018.77
8.0.290.0040.00417.05
8.0.280.0000.00718.42
8.0.270.0000.00817.07
8.0.260.0040.00417.14
8.0.250.0070.00017.20
8.0.240.0040.00417.11
8.0.230.0040.00417.09
8.0.220.0040.00417.11
8.0.210.0000.00717.05
8.0.200.0000.00817.12
8.0.190.0000.00817.20
8.0.180.0000.00817.19
8.0.170.0050.00317.22
8.0.160.0000.00717.02
8.0.150.0030.00517.11
8.0.140.0030.00617.09
8.0.130.0030.00513.54
8.0.120.0000.00917.13
8.0.110.0050.00317.01
8.0.100.0020.00517.15
8.0.90.0000.00716.95
8.0.80.0120.00617.04
8.0.70.0090.00017.04
8.0.60.0030.00517.03
8.0.50.0040.00417.04
8.0.30.0080.01217.26
8.0.20.0070.01317.47
8.0.10.0040.00417.13
8.0.00.0060.01117.00
7.4.330.0000.00515.15
7.4.320.0040.00416.66
7.4.300.0000.00716.90
7.4.290.0030.00316.68
7.4.280.0050.00316.71
7.4.270.0040.00416.77
7.4.260.0040.00716.70
7.4.250.0030.00516.71
7.4.240.0030.00416.77
7.4.230.0030.00316.51
7.4.220.0090.00916.80
7.4.210.0100.00716.87
7.4.200.0040.00416.80
7.4.190.0000.00717.04
7.4.160.0070.01016.61
7.4.150.0070.01117.40
7.4.140.0040.01417.86
7.4.130.0160.00216.84
7.4.120.0050.01516.74
7.4.110.0090.01016.75
7.4.100.0180.00016.80
7.4.90.0080.00816.61
7.4.80.0100.01319.39
7.4.70.0160.00616.62
7.4.60.0060.01616.64
7.4.50.0030.00616.49
7.4.40.0070.01022.77
7.4.30.0090.01216.77
7.4.00.0100.00715.18
7.3.330.0030.00313.55
7.3.320.0000.00713.61
7.3.310.0000.00716.71
7.3.300.0000.00716.42
7.3.290.0070.00716.55
7.3.280.0120.00416.50
7.3.270.0090.00917.40
7.3.260.0110.00916.48
7.3.250.0140.00416.68
7.3.240.0070.01016.82
7.3.230.0060.01216.60
7.3.210.0170.00416.55
7.3.200.0110.00619.39
7.3.190.0090.01216.77
7.3.180.0060.01016.79
7.3.170.0120.00416.91
7.3.160.0130.00316.59
7.3.120.0040.01215.04
7.3.110.0070.01015.19
7.3.100.0060.00814.92
7.3.90.0060.00915.05
7.3.80.0080.00615.04
7.3.70.0060.00814.95
7.3.60.0070.01015.10
7.3.50.0050.00714.92
7.3.40.0110.00515.11
7.3.30.0060.00815.15
7.3.20.0100.00316.81
7.3.10.0030.00816.82
7.3.00.0050.00716.77
7.2.330.0060.01116.89
7.2.320.0000.01716.89
7.2.310.0090.00916.67
7.2.300.0100.00716.87
7.2.290.0120.00617.00
7.2.250.0050.01515.25
7.2.240.0070.01315.07
7.2.230.0080.00515.13
7.2.220.0060.00815.24
7.2.210.0030.01015.29
7.2.200.0040.00915.15
7.2.190.0060.01215.26
7.2.180.0080.00615.13
7.2.170.0030.01315.11
7.2.00.0040.01219.81
7.1.330.0060.00915.89
7.1.320.0050.00715.77
7.1.310.0050.00715.94
7.1.300.0060.01015.88
7.1.290.0070.00615.95
7.1.280.0050.00915.81
7.1.270.0050.01016.06
7.1.260.0050.00716.02
7.1.100.0000.01218.65
7.1.70.0000.01117.50
7.1.60.0060.01919.31
7.1.50.0110.00717.28
7.1.00.0000.05722.31
7.0.200.0030.01016.66
7.0.140.0000.07722.09
7.0.100.0100.05319.94
7.0.90.0070.07719.91
7.0.80.0070.08019.96
7.0.70.0070.07719.88
7.0.60.0000.05319.89
7.0.50.0170.07020.28
7.0.40.0070.09020.18
7.0.30.0130.08020.11
7.0.20.0200.06020.18
7.0.10.0070.08320.12
7.0.00.0070.08720.09
5.6.280.0000.07320.78
5.6.250.0100.07020.64
5.6.240.0200.06320.69
5.6.230.0000.07720.61
5.6.220.0030.05720.67
5.6.210.0200.06720.59
5.6.200.0070.09021.06
5.6.190.0030.05021.07
5.6.180.0230.07021.05
5.6.170.0130.08021.06
5.6.160.0070.08021.10
5.6.150.0070.05021.13
5.6.140.0030.06321.11
5.6.130.0170.07021.04
5.6.120.0030.06021.07
5.6.110.0130.07021.11
5.6.100.0130.07321.04
5.6.90.0100.04720.95
5.6.80.0100.07020.37
5.6.70.0100.07320.34
5.6.60.0070.06020.35
5.6.50.0000.09320.48
5.6.40.0170.06720.49
5.6.30.0030.04020.43
5.6.20.0070.04720.39
5.6.10.0100.08020.39
5.6.00.0230.06320.37
5.5.380.0030.08320.38
5.5.370.0130.04720.47
5.5.360.0000.07320.40
5.5.350.0070.08720.39
5.5.340.0070.08320.83
5.5.330.0030.04320.95
5.5.320.0230.06020.86
5.5.310.0130.04320.85
5.5.300.0000.08720.89
5.5.290.0000.08720.67
5.5.280.0070.08020.95
5.5.270.0100.05720.85
5.5.260.0030.05020.84
5.5.250.0100.07720.48
5.5.240.0100.04020.34
5.5.230.0200.06020.29
5.5.220.0100.07720.22
5.5.210.0100.05720.32
5.5.200.0170.06020.30
5.5.190.0170.07320.26
5.5.180.0100.04320.27
5.5.160.0130.07720.17
5.5.150.0070.07020.29
5.5.140.0100.07320.20
5.5.130.0100.08020.02
5.5.120.0070.04020.22
5.5.110.0070.06720.23
5.5.100.0030.07720.14
5.5.90.0100.05020.19
5.5.80.0170.06320.00
5.5.70.0130.07720.09
5.5.60.0070.04020.05
5.5.50.0070.08020.10
5.5.40.0130.07319.98
5.5.30.0130.05319.95
5.5.20.0100.07720.15
5.5.10.0130.08020.00
5.5.00.0070.07020.09
5.4.450.0070.08019.36
5.4.440.0100.03719.49
5.4.430.0030.07719.50
5.4.420.0170.06319.46
5.4.410.0070.05319.36
5.4.400.0070.04019.23
5.4.390.0130.07319.13
5.4.380.0100.06019.12
5.4.370.0100.07018.88
5.4.360.0030.08719.09
5.4.350.0030.06719.10
5.4.340.0170.07018.95
5.4.320.0070.08019.18
5.4.310.0170.06719.05
5.4.300.0000.09019.15
5.4.290.0030.06019.10
5.4.280.0130.03318.84
5.4.270.0100.07018.94
5.4.260.0100.07319.18
5.4.250.0100.08019.04
5.4.240.0130.05318.81
5.4.230.0000.06719.08
5.4.220.0030.04319.03
5.4.210.0070.05318.89
5.4.200.0100.07019.03
5.4.190.0100.06018.86
5.4.180.0070.07018.89
5.4.170.0000.05319.02
5.4.160.0030.04718.96
5.4.150.0070.07718.83
5.4.140.0070.05016.46
5.4.130.0070.05316.44
5.4.120.0100.07016.40
5.4.110.0000.07716.55
5.4.100.0070.07316.32
5.4.90.0100.05316.51
5.4.80.0070.06716.36
5.4.70.0170.05016.43
5.4.60.0100.07716.47
5.4.50.0130.06016.34
5.4.40.0000.05016.41
5.4.30.0130.06016.33
5.4.20.0070.07316.39
5.4.10.0070.07316.41
5.4.00.0070.04315.65
5.3.290.0070.04314.79
5.3.280.0070.07714.68
5.3.270.0130.07014.58
5.3.260.0000.08014.61
5.3.250.0230.05014.66
5.3.240.0030.07314.72
5.3.230.0070.06314.57
5.3.220.0100.07014.61
5.3.210.0130.07014.65
5.3.200.0130.03314.66
5.3.190.0030.08714.57
5.3.180.0070.07014.73
5.3.170.0100.06314.60
5.3.160.0130.06014.59
5.3.150.0070.04014.55
5.3.140.0070.06714.70
5.3.130.0100.07014.64
5.3.120.0030.05714.62
5.3.110.0030.07014.68
5.3.100.0270.06314.01
5.3.90.0030.07314.18
5.3.80.0130.04314.10
5.3.70.0070.04013.96
5.3.60.0070.04014.08
5.3.50.0100.06313.96
5.3.40.0000.05313.97
5.3.30.0030.07013.95
5.3.20.0030.07713.82
5.3.10.0070.06013.58
5.3.00.0030.07313.67
5.2.170.0030.05712.16
5.2.160.0000.03712.16
5.2.150.0100.05312.16
5.2.140.0100.06012.16
5.2.130.0070.06012.16
5.2.120.0030.06312.16
5.2.110.0070.05012.16
5.2.100.0100.05712.16
5.2.90.0000.03312.16
5.2.80.0030.04012.16
5.2.70.0030.06012.16
5.2.60.0000.06312.16
5.2.50.0030.06712.16
5.2.40.0030.06312.16
5.2.30.0070.03012.16
5.2.20.0000.05312.16
5.2.10.0100.05712.16
5.2.00.0070.05012.16
5.1.60.0100.02312.16
5.1.50.0030.05712.16
5.1.40.0070.03012.16
5.1.30.0030.04712.16
5.1.20.0030.06012.16
5.1.10.0000.03312.16
5.1.00.0070.03012.16
5.0.50.0000.02712.16
5.0.40.0000.04312.16
5.0.30.0100.05012.16
5.0.20.0030.04012.16
5.0.10.0000.02712.16
5.0.00.0070.05712.16
4.4.90.0070.03312.16
4.4.80.0030.04012.16
4.4.70.0000.03312.16
4.4.60.0070.03312.16
4.4.50.0030.01712.16
4.4.40.0000.03012.16
4.4.30.0030.03312.16
4.4.20.0030.03312.16
4.4.10.0030.03312.16
4.4.00.0000.03012.16
4.3.110.0000.03312.16
4.3.100.0000.03712.16
4.3.90.0000.03712.16
4.3.80.0000.04312.16
4.3.70.0030.03012.16
4.3.60.0030.03312.16
4.3.50.0130.01712.16
4.3.40.0000.06012.16
4.3.30.0000.02312.16
4.3.20.0030.03312.16
4.3.10.0030.01712.16
4.3.00.0000.03712.16

preferences:
41.73 ms | 401 KiB | 5 Q