Advertisement
GarryLaly

Function Bulatkan Angka (Statis)

Mar 13th, 2014
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.33 KB | None | 0 0
  1. <?php
  2. $angka = 8161824.6;
  3. $potong1 = substr($angka, 0, 3);
  4. $potong2 = ceil(substr($angka, 3, strlen($angka)));
  5. $bulat = substr($potong2, 1, 1);
  6. $bulat1 = substr($potong2, 0, 1);
  7. $bulat2 = $bulat>=5?$bulat1+1:$bulat1;
  8. $nol = "";
  9. for ($i = 0;$i < strlen($potong2)-1;$i++) {
  10.     $nol .= "0";
  11. }
  12. echo $potong1.$bulat2.$nol;
  13. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement