PDA

View Full Version : php trim price



suzkaw
04-17-2004, 02:57 PM
I am trying to create an allposters site after reading the review.
Well everything is coming along fine until I went to print the price out. It seems they use a four digit decimal for some reason. Example: $32.0000
Well I looked at php.net under the trim function but couldn't find anything on how to trim from the end. Does anyone have any ideas on how to do this?

Chris
04-17-2004, 05:48 PM
If you're inserting into a DB you could set the mysql field parameters to use just 2 decimals.

eMEraLdwPn
04-17-2004, 08:57 PM
and if you're not,
$price = round($price, 2);

trim is used to eliminate whitespace at the end of a string

suzkaw
04-17-2004, 09:12 PM
Thanks guys. I am storing the info in a db but didn't think of doing it that way. Thanks a ton for both answers!