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