Jump to content


Photo

Displaying thousands with a comma!


  • Please log in to reply
3 replies to this topic

#1 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 20 September 2006 - 12:54 PM

Ok quick thing

If there is a price inserted into the databae (as a double) say: 295000, how can i then get that to display as such: 295,000
http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 20 September 2006 - 12:58 PM

<?php
$price = number_format($price,2,".",",");
?>


#3 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 20 September 2006 - 01:03 PM

I actuall did it like this:

$tmp_price = $properties['price'];
$price = chunk_split("$tmp_price", 3, ","); 
echo "£" . $price;

But now i have a comma at the end of the string, how can i remove this?
http://thewebsolutionprovider.com - A Solution For Everything Web!

#4 wildteen88

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

Posted 20 September 2006 - 01:29 PM

Why dont you just use the number_format functon? It does all the formating for you. All you need to do is provide the thousands and decimal seperator. See SA's post above.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users