<?php
$from = 'ľľščťžýáíŕďňäô'; // these chars are in UTF-8
$to = 'llsctzyairdnao';
$str = 'Kŕdeľ ďatľov učí koňa žrať kôru.';
// bad because $from and $to are related by their byte offsets
echo strtr($str, $from, $to);
echo "\n---\n";
// good because not evaluated by individual bytes
$trans = [
'ľ' => 'l',
'š' => 's',
'č' => 'c',
'ť' => 't',
'ž' => 'z',
'ý' => 'y',
'á' => 'a',
'í' => 'i',
'ŕ' => 'r',
'ď' => 'd',
'ň' => 'n',
'ä' => 'a',
'ô' => 'o',
];
echo strtr($str, $trans);
preferences:
26.04 ms | 404 KiB | 5 Q