Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ziyahan/7784925 to your computer and use it in GitHub Desktop.
Save ziyahan/7784925 to your computer and use it in GitHub Desktop.
TL Para Birimi Tutarı Yazıya Çevirmek(PHP)
function cevir($sayi, $separator) {
$sayarr = explode($separator,$sayi);
$str = "";
$items = array(
array("", ""),
array("BIR", "ON"),
array("IKI", "YIRMI"),
array("UC", "OTUZ"),
array("DORT", "KIRK"),
array("BES", "ELLI"),
array("ALTI", "ALTMIS"),
array("YEDI", "YETMIS"),
array("SEKIZ", "SEKSEN"),
array("DOKUZ", "DOKSAN")
);
for ($eleman = 0; $eleman<count($sayarr); $eleman++) {
for ($basamak = 1; $basamak <=strlen($sayarr[$eleman]); $basamak++) {
$basamakd = 1 + (strlen($sayarr[$eleman]) - $basamak);
try {
switch ($basamakd) {
case 6:
$str = $str . " " . $items[substr($sayarr[$eleman],$basamak - 1,1)][0] . " YUZ";
break;
case 5:
$str = $str . " " . $items[substr($sayarr[$eleman],$basamak - 1,1)][1];
break;
case 4:
if ($items[substr($sayarr[$eleman],$basamak - 1,1)][0] != "BIR") $str = $str . " " . $items[substr($sayarr[$eleman],$basamak - 1,1)][0] . " BIN";
else $str = $str . " BIN";
break;
case 3:
if($items[substr($sayarr[$eleman],$basamak - 1,1)][0]=="") {
$str.=" ";
}
elseif ($items[substr($sayarr[$eleman],$basamak - 1,1)][0] != "BIR" ) $str = $str . " " . $items[substr($sayarr[$eleman],$basamak - 1,1)][0] . " YUZ";
else $str = $str . " YUZ";
break;
case 2:
$str = $str . " " . $items[substr($sayarr[$eleman],$basamak - 1,1)][1];
break;
default:
$str = $str . " " . $items[substr($sayarr[$eleman],$basamak - 1,1)][0];
break;
}
} catch (Exception $err) {
echo $err->getMessage();
break;
}
}
if ($eleman< 1) $str = $str . " TL";
else {
if ($sayarr[1] != "00") $str = $str . " KRS";
}
}
return $str;
}
@Behcet-zz
Copy link

Teşekkürler, ancak
(2,087.50 TL) YİRMİ BİN SEKSEN YEDİ TL ELLİ BİN KRŞ
şeklinde çevirdi

@Turyaps
Copy link

Turyaps commented Jul 20, 2020

yüz on bir bin i okuyamıyor. diğerleri ok ama örnek 111111 şeklinde deneyince yüz on bin yüz on bir şeklinde ilk binlik teki biri atliyor.

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