Hello List.
In an earlier post, I received help with a custom function to round
decimals off (the custom function provided by Adam Richardson is
below).
However in my MySQL db, when I have values with only 1 decimal
point, I need the value PHP returns to display as 2. For example,
3.8 needs to display as 3.80.
My line of code that calls the custom function looks like this:
$my_price = round_to_half_cent(number_format($my_price, 3, '.', ','));
When the value of $my_price is 3.81, it returns 3.81. However, when
the value of $my_price is 3.8 that is what it returns.
How can I force the formatting of my_price to always contain either
2 or 3 decimal points (3 if the original number contains 3 or more
decimal points to begin with)
Thanks,
--Rick
Rick:
Okay so 3.8 is stored in the database and not as 3.80 -- but that's
not a problem. What you have is a display problem so use one of the
many PHP functions to display numbers and don't worry about how it's
stored.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php