@ 2016-01-20T16:34:49Z <?php
$unclean_name = 'File name %20 %20 %2C Décor \/. /. . z \... y \...... x ./ “This name” is & 462^^ not = 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);
} else {
$str = preg_replace("/([^\w\d\\" . $sep . "\[\]\(\).])/", '', $str);
}
return substr($str, 0, $trim);
}
// get or set a default file name in case all chars are trimmed from $str then ensure 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
return str_file_filter($str, $sep) . str_file_filter('.' . $ext, '', true);
} else {
return str_file_filter($str, $sep);
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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).
Version System time (s) User time (s) Memory (MiB) 7.0.2 0.037 0.073 20.25 7.0.1 0.003 0.047 20.15 7.0.0 0.003 0.077 20.05 5.6.17 0.023 0.043 20.47 5.6.16 0.003 0.053 20.50 5.6.15 0.003 0.040 18.19 5.6.14 0.013 0.070 18.14 5.6.13 0.007 0.080 18.14 5.6.12 0.007 0.057 21.13 5.6.11 0.000 0.043 21.12 5.6.10 0.017 0.077 21.00 5.6.9 0.010 0.037 21.01 5.6.8 0.007 0.060 20.39 5.5.31 0.027 0.073 20.14 5.5.30 0.010 0.033 17.95 5.5.29 0.010 0.070 18.03 5.5.28 0.017 0.073 20.78 5.5.27 0.003 0.077 20.88 5.5.26 0.007 0.080 20.98 5.5.25 0.027 0.070 20.48 5.5.24 0.030 0.053 20.20
preferences:dark mode live preview
142.42 ms | 1394 KiB | 7 Q