Jump to content


Photo

*SOLVED* Format Variables


  • Please log in to reply
3 replies to this topic

#1 chrisbcats

chrisbcats
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 06 June 2006 - 07:21 AM

How do I format php variables?

I have several calculated php variables. How do I format the variables in decimal and whole number format?

ex:
$netValue = 874.76233
$net = 8952038

I need the variables to return:
$netValue = 874.76
$net = 8,952,038


#2 KrisNz

KrisNz
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts
  • LocationAuckland, New Zealand

Posted 06 June 2006 - 07:41 AM

[a href=\"http://php.net/printf\" target=\"_blank\"]printf[/a] is what you're after

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 June 2006 - 03:09 PM

or [a href=\"http://uk2.php.net/manual/en/function.number-format.php\" target=\"_blank\"]number_format[/a] [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]

#4 chrisbcats

chrisbcats
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 07 June 2006 - 03:13 AM

Thank you both! I better understood number_format.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users