3v4l.org

run code in 300+ PHP versions simultaneously
<?php $unclean_name = 'File name %20 %20 %2C Décor \/. /. . z \... y \...... x ./ “This name” is & 462^^ not &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = that grrrreat -][09]()1234747) sdlfjfkleq flekqjelkjqlk fjlkqe fqf'; $seperator = '_'; $fallback_name = 'generated__' . date('Y-m-d_H-m_A'); $max_chars = '180'; $file_extension = '....ta()r.gz[]'; echo str_file($unclean_name, $seperator, $fallback_name, $max_chars, $file_extension); function str_file( $str, $sep = '_', $default = '', $trim = 180, $ext = '' ) { // file name filters used to clean and prepare a string function str_file_filter( $str, $sep = '_', $strict = false, $trim = 180 ) { $str = strip_tags(strtolower($str)); $str = preg_replace("/&#?[a-z0-9]{2,8};/i", '', $str); $str = str_replace("%20", ' ', $str); // $str = preg_replace("/\s+/", $sep, $str); $str = preg_replace("/\.+/", '.', $str); if ($strict) { $str = preg_replace("/([^\w\d\\" . $sep . ".])/", '', $str); // allow only words, digits, underscore, period } else { $str = preg_replace("/([^\w\d\\" . $sep . "\[\]\(\).])/", '', $str); // allow only words, digits, underscore, period, [], () } return substr($str, 0, $trim); } // get or set a default file name in case all chars are trimmed from $str ensuring there is an id at tail if (empty($str) && empty($default)) { $str = 'no_name__' . date('Y-m-d_H-m_A') . '__' . uniqid(); } elseif (empty($str)) { $str = $default; } // run $str and/or $ext through filters to clean up and remove special chars if (!empty($ext)) { $ext = '.' . $ext; // ensure there is at least 1 period return str_file_filter($str, $sep) . str_file_filter($ext, '', true); } else { return str_file_filter($str, $sep); } }

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)
7.4.10.0030.00915.14
7.4.00.0050.01315.21
7.3.130.0110.00815.23
7.3.120.0090.01015.06
7.3.110.0080.01115.00
7.3.100.0050.01214.89
7.3.90.0060.00915.06
7.3.80.0070.00715.12
7.3.70.0110.00515.09
7.3.60.0050.01115.09
7.3.50.0060.00815.06
7.3.40.0060.00815.09
7.3.30.0070.00615.00
7.3.20.0070.00416.91
7.3.10.0070.00716.86
7.3.00.0090.00516.75
7.2.260.0100.01015.38
7.2.250.0100.00815.21
7.2.240.0050.01215.12
7.2.230.0070.00915.45
7.2.220.0060.01215.39
7.2.210.0060.01015.27
7.2.200.0080.00915.18
7.2.190.0110.00415.37
7.2.180.0040.01115.12
7.2.170.0080.00915.32
7.2.160.0030.01715.16
7.2.150.0000.01217.11
7.2.140.0090.00617.00
7.2.130.0080.00917.19
7.2.120.0070.01216.89
7.2.110.0070.00917.16
7.2.100.0150.00816.79
7.2.90.0110.01117.04
7.2.80.0120.01117.05
7.2.70.0080.01116.93
7.2.60.0110.01017.05
7.2.50.0090.00717.12
7.2.40.0060.01617.06
7.2.30.0090.01117.14
7.2.20.0140.00716.92
7.2.10.0110.00616.84
7.2.00.0070.01517.10
7.1.330.0060.01016.02
7.1.320.0070.00816.06
7.1.310.0050.00916.18
7.1.300.0060.01015.94
7.1.290.0050.00915.93
7.1.280.0050.01016.02
7.1.270.0080.01015.89
7.1.260.0050.00715.99
7.1.250.0080.00716.00
7.1.240.0000.01315.98
7.1.230.0110.00016.13
7.1.220.0030.01015.91
7.1.210.0000.01115.90
7.1.200.0030.01015.95
7.1.190.0070.00715.97
7.1.180.0080.00315.79
7.1.170.0040.00416.20
7.1.160.0060.00616.19
7.1.150.0070.00716.15
7.1.140.0050.00516.17
7.1.130.0100.00316.18
7.1.120.0000.00916.26
7.1.110.0030.00716.17
7.1.100.0030.01017.34
7.1.90.0000.01115.76
7.1.80.0000.01116.16
7.1.70.0060.00516.79
7.1.60.0080.01017.69
7.1.50.0050.01416.63
7.1.40.0070.00316.21
7.1.30.0000.01116.12
7.1.20.0030.00816.06
7.1.10.0060.00916.24
7.1.00.0030.04419.27
7.0.330.0070.00715.27
7.0.320.0100.00315.45
7.0.310.0060.00615.71
7.0.300.0100.00315.55
7.0.290.0100.00715.52
7.0.280.0090.00315.76
7.0.270.0070.00715.63
7.0.260.0030.00615.71
7.0.250.0070.00715.81
7.0.240.0100.00315.71
7.0.230.0070.00715.85
7.0.220.0070.00715.92
7.0.210.0050.00815.64
7.0.200.0210.00615.43
7.0.190.0030.01115.44
7.0.180.0030.01015.75
7.0.170.0120.00315.52
7.0.160.0030.01115.84
7.0.150.0040.01115.62
7.0.140.0120.00315.51
7.0.130.0000.01015.68
7.0.120.0030.00715.50
7.0.110.0040.01115.44
7.0.100.0090.04417.62
7.0.90.0090.03617.90
7.0.80.0120.04317.89
7.0.70.0080.04317.88
7.0.60.0050.04917.69
7.0.50.0030.04817.94
7.0.40.0080.04416.78
7.0.30.0080.03516.80
7.0.20.0120.04017.04
7.0.10.0050.04716.93
7.0.00.0050.04116.83
5.6.400.0070.00414.80
5.6.390.0040.01214.73
5.6.380.0060.00914.46
5.6.370.0070.00414.80
5.6.360.0000.01114.26
5.6.350.0060.00914.18
5.6.340.0080.00414.45
5.6.330.0040.00814.22
5.6.320.0030.00914.75
5.6.310.0060.00314.46
5.6.300.0060.00914.70
5.6.290.0050.00514.55
5.6.280.0030.04117.55
5.6.270.0060.00614.40
5.6.260.0080.00814.38
5.6.250.0100.04217.71
5.6.240.0100.04317.74
5.6.230.0050.03117.56
5.6.220.0090.04217.46
5.6.210.0070.03117.47
5.6.200.0080.04717.83
5.6.190.0080.02517.83
5.6.180.0070.03317.78
5.6.170.0080.04317.84
5.6.160.0090.04017.82
5.6.150.0090.04217.80
5.6.140.0090.04017.80
5.6.130.0090.04017.87
5.6.120.0070.04717.75
5.6.110.0150.04017.80
5.6.100.0070.04817.81
5.6.90.0070.03417.58
5.6.80.0030.03317.36
5.6.70.0070.04117.48
5.6.60.0080.02217.38
5.6.50.0120.03817.50
5.6.40.0100.03917.51
5.6.30.0100.04217.45
5.6.20.0120.03717.39
5.6.10.0080.04017.49
5.6.00.0070.03417.44
5.5.380.0150.03817.47
5.5.370.0070.04217.52
5.5.360.0080.03817.49
5.5.350.0070.02717.39
5.5.340.0030.04517.59
5.5.330.0080.04417.81
5.5.320.0070.04617.48
5.5.310.0070.04017.47
5.5.300.0080.04317.59
5.5.290.0080.04117.66
5.5.280.0120.03817.51
5.5.270.0120.03017.65
5.5.260.0080.04517.60
5.5.250.0100.03317.51
5.5.240.0050.02517.32
5.5.230.0060.03917.26
5.5.220.0050.04617.33
5.5.210.0050.03317.27
5.5.200.0020.04017.23
5.5.190.0070.04017.29
5.5.180.0030.02817.23
5.5.170.0000.01114.65
5.5.160.0090.04117.31
5.5.150.0030.03517.29
5.5.140.0030.03017.33
5.5.130.0090.04117.34
5.5.120.0100.04317.29
5.5.110.0100.04017.26
5.5.100.0060.04517.27
5.5.90.0050.04617.13
5.5.80.0050.04517.35
5.5.70.0090.03817.28
5.5.60.0020.04717.36
5.5.50.0050.02517.14
5.5.40.0070.03817.29
5.5.30.0100.04117.05
5.5.20.0050.04117.30
5.5.10.0060.03417.38
5.5.00.0070.02517.11

preferences:
38.9 ms | 400 KiB | 5 Q