Jump to content


Photo

Format a number


  • Please log in to reply
2 replies to this topic

#1 komquat

komquat
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts
  • LocationHoughton, MI

Posted 08 August 2006 - 03:21 PM

I need help formatting a number to a set decimal place.

Please help

Thanks in advance

#2 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 08 August 2006 - 03:24 PM

<?php

$number = 1234.56;

$a = number_format($number, 2, '.', ',');

$b = number_format($number, 3, '.', ',');

echo "$a<br><br>$b";

?>


#3 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 09 August 2006 - 09:57 AM

was that ok mate?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users