$table = array( 'Э' =>array( 'A', 'E'), ' П'=>'P', 'Л'=>'L', 'C'=>array('C', 'S'));
function (){
//magic;//
}
function('ЭПЛС') // return array("APLS", "EPLS", "APLC", "EPLC");
Реализация :
public static function translit($str){
if($str != convert_cyr_string($str , 'w' , 'k')){
$table = array( 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Ж' => 'ZH', 'З' => 'Z', 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', 'Ш' => 'SH', 'Щ' => 'CSH', 'Ь' => '', 'Ы' => 'Y', 'Ъ' => '', 'Э' => array('E','A'), 'Ю' => 'YU', 'Я' => 'YA', 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => "l", 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'csh', 'ь' => '', 'ы' => 'y', 'ъ' => '', 'э' => array('e','a'), 'ю' => 'yu', 'я' => 'ya');
$str = preg_split('//u',$str,-1,PREG_SPLIT_NO_EMPTY);
$output = array();
foreach ($str as $key => $valuestr) {
$now = $table[$valuestr];
if(is_array($now)){
if(count($output) == 0){
$output[0] = "";
}
$work = array();
foreach ($now as $keytwo => $va) {
foreach ($output as $key => &$value) {
$work[] = $value.$va;
}
}
$output = $work;
}else{
if(count($output) == 0){
$output[0] = $now;
}else{
foreach ($output as $key => &$value) {
$value .= $now;
}
}
}
}
return $output;
}else{
return false;
}
}