Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.26 KB | None | 0 0
  1. function cutNum($num, $precision = 2) {
  2.     $posOfDecimal = stripos($num, '.');
  3.     if($posOfDecimal !== false){
  4.         $integerPart = floor($num);
  5.         $trimmedDecimal = substr($num, $posOfDecimal, $precision + 1);
  6.         return $integerPart . $trimmedDecimal;
  7.     }
  8.     return $num;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement