Results 1 to 4 of 4

Thread: php trim price

  1. #1
    Registered
    Join Date
    Apr 2004
    Posts
    14

    php trim price

    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?

  2. #2
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    If you're inserting into a DB you could set the mysql field parameters to use just 2 decimals.
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  3. #3
    and if you're not,
    $price = round($price, 2);

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

  4. #4
    Registered
    Join Date
    Apr 2004
    Posts
    14
    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!

Similar Threads

  1. Review: Professional PHP Programming
    By Chris in forum Books
    Replies: 6
    Last Post: 07-17-2013, 05:26 AM
  2. More disk space, more bandwidth at the SAME PRICE!
    By Helen in forum The Marketplace
    Replies: 19
    Last Post: 04-26-2004, 10:59 AM
  3. Learning how to create PHP database driven sites online...
    By incka in forum Website Programming & Databases
    Replies: 15
    Last Post: 01-23-2004, 03:18 PM
  4. How do I make my PHP thing list in name order?
    By incka in forum Website Programming & Databases
    Replies: 8
    Last Post: 12-11-2003, 07:18 AM
  5. PHP, ODBC, and Unicode compatibilities...
    By Stevens in forum Website Programming & Databases
    Replies: 4
    Last Post: 10-14-2003, 09:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •