Skip to content

Instantly share code, notes, and snippets.

@kooler62
Last active September 29, 2015 06:50
Show Gist options
  • Select an option

  • Save kooler62/f14a566fd0d9c36e4f0a to your computer and use it in GitHub Desktop.

Select an option

Save kooler62/f14a566fd0d9c36e4f0a to your computer and use it in GitHub Desktop.
транслит
<?
function translit($str) {
$rus = array(',','?','!','–',' ','А', 'Б', 'В', 'Г', 'Д', 'Е','Є', 'Ё', 'Ж', 'З', 'И','І','Ї', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я',
'а', 'б', 'в', 'г', 'д', 'е', 'є', 'ё', 'ж', 'з', 'и','і','ї', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я');
$lat = array('','','','-','-','A', 'B', 'V', 'G', 'D', 'E', 'E', 'E', 'Gh', 'Z', 'I','I','Yi', 'Y', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'H', 'Ts', 'Ch', 'Sh', 'Sch', 'Y', 'Y', 'Y', 'E', 'Yu', 'Ya',
'a', 'b', 'v', 'g', 'd', 'e', 'e', 'e', 'gh', 'z', 'i','i','yi', 'y', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'ts', 'ch', 'sh', 'sch', 'y', 'y', 'y', 'e', 'yu', 'ya');
//return str_replace($rus, $lat, $str);
$new=str_replace($rus, $lat, $str);
$what = array('---','--','.-');
$be=array('-','-','-');
return str_replace($what, $be, $new);
}
//приводим к нижнему регистру
echo mb_strtolower( translit("Притча про кривду та картоплину"));
@kooler62
Copy link
Author

зделать повторную проверку и исправление таких мест
--- => -
.- => . или -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment