Created
December 4, 2013 09:44
-
-
Save ziyahan/7784925 to your computer and use it in GitHub Desktop.
TL Para Birimi Tutarı Yazıya Çevirmek(PHP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.