Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

konversi angka ke huruf

By: a guest on May 22nd, 2013  |  syntax: PHP  |  size: 1.38 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //view
  2. <form method="post" action="<?= base_url(); ?>home/angka">
  3.         <tr><td>masukkan angka</td><td>:</td><td><input type="text" name="angka" id="nik"></input></td><td><span id="bilangan"></span></td></tr>
  4.         <tr><td><input type="submit" value="Proses" id="TbProses2"></input></td></tr>
  5. </form>
  6.  
  7.  
  8. // controller
  9. function angka()
  10.         {
  11.                 //$angka = $_POST['angka'];
  12.                 $angka = $this->input->post('angka');
  13.                 $abil = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
  14.        
  15.                 if ($angka < 12)
  16.                 return " " . $abil[$angka];
  17.         elseif ($angka < 20)
  18.                 return $this->angka($angka - 10) . " belas";
  19.         elseif ($angka < 100)
  20.                 return $this->angka($angka / 10) . " puluh" . $this->angka($angka % 10);
  21.         elseif ($angka < 200)
  22.                 return " seratus" . $this->angka($angka - 100);
  23.         elseif ($angka < 1000)
  24.                 return $this->angka($angka / 100) . " ratus" . $this->angka($angka % 100);
  25.         elseif ($angka < 2000)
  26.                 return " seribu" . $this->angka($angka - 1000);
  27.         elseif ($angka < 1000000)
  28.                 return $this->angka($angka / 1000) . " ribu" . $this->angka($angka % 1000);
  29.         elseif ($angka < 1000000000)
  30.                 return $this->angka($angka / 1000000) . " juta" . $this->angka($angka % 1000000);
  31.        
  32.         }
clone this paste RAW Paste Data