Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Location
    Oakham England
    Posts
    503

    Add Decimal Point

    Hey,

    I have the following types of numbers 10000 or 150 and I need PHP to take that and add a . before the last 2 so the above would become.

    100.00 and 1.50

    Thanks.
    Dan
    Streama - Your WordPress Friend
    http://www.streama.co.uk

  2. #2
    Join Date
    Mar 2003
    Location
    Kathmandu, Nepal
    Posts
    3,982
    number_format($number/100,2);

    something like that should do it.
    Kevin Ohashi - Founder of ReviewSignal.com - Honest Web Hosting Reviews
    Check out my 2021 WordPress Hosting Performance Benchmarks, the most comprehensive look at WP hosting performance

  3. #3
    Join Date
    Aug 2007
    Location
    Oakham England
    Posts
    503
    Perfect, Thanks very much for your help!
    Streama - Your WordPress Friend
    http://www.streama.co.uk

  4. #4
    Code:
    str_pad($number, 2, "0", STR_PAD_RIGHT)
    Web Hosting by Brontobytes

  5. #5
    Join Date
    Mar 2003
    Location
    Kathmandu, Nepal
    Posts
    3,982
    Quote Originally Posted by nimonogi View Post
    Code:
    str_pad($number, 2, "0", STR_PAD_RIGHT)
    This isn't correct. It's simply padding a string with zeros and not taking into account the fact you're working with numbers and not strings.
    Kevin Ohashi - Founder of ReviewSignal.com - Honest Web Hosting Reviews
    Check out my 2021 WordPress Hosting Performance Benchmarks, the most comprehensive look at WP hosting performance

Similar Threads

  1. decimal to binary conversions?
    By sTag-Dan in forum Web Hosting Lounge
    Replies: 3
    Last Post: 02-13-2008, 12:24 PM
  2. Decimal problems with number_format()
    By MGCJerry in forum Programming Discussion
    Replies: 4
    Last Post: 02-06-2004, 02:14 PM
  3. What does an add-on domain point to?
    By vito in forum Hosting Software and Control Panels
    Replies: 6
    Last Post: 02-08-2003, 04:34 PM
  4. Binary <-> Decimal Conversion
    By Icheb in forum Programming Discussion
    Replies: 6
    Last Post: 10-15-2002, 06:02 PM
  5. Simple PHP Decimal Help
    By Mr_Predator in forum Programming Discussion
    Replies: 11
    Last Post: 09-28-2002, 11:33 PM

Posting Permissions

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