Last active
September 10, 2023 16:07
-
-
Save trgino/b33d95908188f6c2b20f76d17db30a8f to your computer and use it in GitHub Desktop.
number format without round up
This file contains hidden or 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
<?php | |
function fix_number_format($num, $decimals = 2, $decimals_seperator = '.', $thousands_separator = ','){ | |
$num = floatval($num); | |
$num = number_format( $num, ($decimals + 1), $decimals_seperator, $thousands_separator); | |
$num = substr($num, 0, -1); | |
return $num; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment