Last active
May 1, 2024 07:37
-
-
Save giventofly/315b4d0ce21606e4b582553aba1bc3a4 to your computer and use it in GitHub Desktop.
regex convert russian (cyrillic) to latin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://stackoverflow.com/a/6837426/1911609 | |
function strtolatin($string){ | |
if (strpos($string = htmlentities($string, ENT_QUOTES, 'UTF-8'), '&') !== false){ | |
$string = html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i', '$1', $string), ENT_QUOTES, 'UTF-8'); | |
} | |
return $string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment