Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cutNum($num, $precision = 2) {
- $posOfDecimal = stripos($num, '.');
- if($posOfDecimal !== false){
- $integerPart = floor($num);
- $trimmedDecimal = substr($num, $posOfDecimal, $precision + 1);
- return $integerPart . $trimmedDecimal;
- }
- return $num;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement