Created
January 6, 2020 12:11
-
-
Save waska14/c5a91a373f589dc1e0deebf80dc150d9 to your computer and use it in GitHub Desktop.
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 | |
function geoToLat(string $input): string | |
{ | |
static $mapper = [ | |
'ა' => 'a', | |
'ბ' => 'b', | |
'გ' => 'g', | |
'დ' => 'd', | |
'ე' => 'e', | |
'ვ' => 'v', | |
'ზ' => 'z', | |
'თ' => 'T', | |
'ი' => 'i', | |
'კ' => 'k', | |
'ლ' => 'l', | |
'მ' => 'm', | |
'ნ' => 'n', | |
'ო' => 'o', | |
'პ' => 'p', | |
'ჟ' => 'J', | |
'რ' => 'r', | |
'ს' => 's', | |
'ტ' => 't', | |
'უ' => 'u', | |
'ფ' => 'f', | |
'ქ' => 'q', | |
'ღ' => 'R', | |
'ყ' => 'y', | |
'შ' => 'S', | |
'ჩ' => 'C', | |
'ც' => 'c', | |
'ძ' => 'Z', | |
'წ' => 'w', | |
'ჭ' => 'W', | |
'ხ' => 'x', | |
'ჯ' => 'j', | |
'ჰ' => 'h', | |
]; | |
$chars = preg_split('//u', $input, -1, PREG_SPLIT_NO_EMPTY); | |
$result = array_map(function (string $char) use ($mapper) { | |
return $mapper[$char] ?? $char; | |
}, $chars); | |
return implode('', $result); | |
} | |
$text = 'რუსეთი ოკუპანტია :)'; | |
echo geoToLat($text); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment