3v4l.org

run code in 300+ PHP versions simultaneously
<?php $file = 'ыыыыыыыы'; if (function_exists('transliterator_transliterate') && function_exists('iconv')) { echo 'ICONV Available' .PHP_EOL; } // Remove any trailing dots, as those aren't ever valid file names. $file = rtrim($file, '.'); // Try transliterating the file name using the native php function if (function_exists('transliterator_transliterate') && function_exists('iconv')) { echo 'transliterating YES' .PHP_EOL; // Using iconv to ignore characters that can't be transliterated $file = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', $file)); } $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#'); $name = trim(preg_replace($regex, '', $file)); var_dump($name);

preferences:
25.96 ms | 408 KiB | 5 Q