Results 1 to 3 of 3

Thread: numbers after .

  1. #1
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default numbers after .

    Hello again, i got this:

    $a = "1234560";
    $b = $a / "1000000";

    echo "$b Millions";

    it prints on screen this: 1.234560 Millions

    Now the question, how can i print on screen 1.2 Millions instead?

    PS: ofcourse $a value allways changes, else i would just echo '1.2 Millions'; directly.

    Thanks!

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You could use round() to do that. Using this technique in your application would be something like so:

    Code:
    $a = "1234560";
    $b = $a / "1000000";
    
    echo round($b, 1) . " Millions"; //produces 1.2 Millions
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    Excellent! Thanks you!

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
  •