Skip to content

Instantly share code, notes, and snippets.

@waska14
Created January 6, 2020 12:11
Show Gist options
  • Save waska14/c5a91a373f589dc1e0deebf80dc150d9 to your computer and use it in GitHub Desktop.
Save waska14/c5a91a373f589dc1e0deebf80dc150d9 to your computer and use it in GitHub Desktop.
<?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