The funcion should take all the content of a page .. skip some words, and transliterate from latin to cyrillic all the others. Here goes the code
Code: Select all
<?php
$cyril=array("?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?");
$latin=array("LJ","NJ","A","B","V","G","D","?","E","Ž","Z","I","J","K","L","M","N","O","P","R","S","Š","T","?","U","F","H","C","?","DŽ","Š","lj","nj","a","b","v","g","d","?","e","ž","z","i","j","k","l","m","n","o","p","r","s","š","t","?","u","f","h","c","?","dž","š");
$eng=array("engleski","example");
$content="srpski engleski primer example";
$ar=preg_split("/\b/",$content);
foreach ($ar as $word) {
$skip_this=0;
$output = $word;
for($i=0;$i<count ($eng);$i++){ #if found $eng skip transliteration
$curr_en=$eng[$i];
if ($word == $curr_en) {
$skip_this = 1;
#echo "I found word to skip: ", $output,"\n";
}
}
if ($skip_this !=1 ) {
#echo "This would be transliterated: ",$word,"\n";
for($a=0;$a<count($latin);$a++){ #transliterate latin letters to cyrillic
$current_cyr=$cyril[$a];
$current_lat=$latin[$a];
$output=str_replace($current_lat,$current_cyr,$word);
}
}
$input .= $output;
}
echo "orginal: $content transliterated: $input \n";
?>It's obvious that I'm repeating some stupid mistake .. but I can't figure it out