// how google transliterates ( взимано от тука http://bit.ly/g6ihYg )
$transliterations_lower = array(
'а' => 'a',
'б' => 'b',
'в' => 'v',
'г' => 'g',
'д' => 'd',
'е' => 'e',
'ж' => 'j',
'з' => 'z',
'и' => 'i',
'й' => 'y',
'к' => 'k',
'л' => 'l',
'м' => 'm',
'н' => 'n',
'о' => 'o',
'п' => 'p',
'р' => 'r',
'с' => 's',
'т' => 't',
'у' => 'u',
'ф' => 'f',
'х' => 'h',
'ц' => 'c',
'ч' => 'ch',
'ш' => 'sh',
'щ' => 'sht',
'ъ' => 'a',
'ь' => '',
'ю' => 'yu',
'я' => 'ya',
);
$config['transliterations'] = array();
foreach ($transliterations_lower as $bg => $en)
{
$config['transliterations'][$bg] = $en;
$config['transliterations'][mb_strtoupper($bg, 'UTF-8')] = $en;
}
function transliterate($string)
{
global $transliterations;
$new_string = '';
for ($i = 0; $i < strlen($string); $i++)
{
$char = mb_substr($string, $i, 1, 'UTF-8');
if (array_key_exists($char, $transliterations))
$new_string .= $transliterations[$char];
else
$new_string .= $char;
}
return $new_string;
}
$string = transliterate("момичета"); // momicheta
Аз ползвам е това за транслитерация. Не е смарти, ама що годе лесно се нагажда:
Код:// how google transliterates ( взимано от тука http://bit.ly/g6ihYg ) $transliterations_lower = array( 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ж' => 'j', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sht', 'ъ' => 'a', 'ь' => '', 'ю' => 'yu', 'я' => 'ya', ); $config['transliterations'] = array(); foreach ($transliterations_lower as $bg => $en) { $config['transliterations'][$bg] = $en; $config['transliterations'][mb_strtoupper($bg, 'UTF-8')] = $en; } function transliterate($string) { global $transliterations; $new_string = ''; for ($i = 0; $i < strlen($string); $i++) { $char = mb_substr($string, $i, 1, 'UTF-8'); if (array_key_exists($char, $transliterations)) $new_string .= $transliterations[$char]; else $new_string .= $char; } return $new_string; } $string = transliterate("момичета"); // momicheta