Jump to content

Archived

This topic is now archived and is closed to further replies.

glenelkins

Displaying thousands with a comma!

Recommended Posts

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

Share this post


Link to post
Share on other sites
[code]<?php
$price = number_format($price,2,".",",");
?>[/code]

Share this post


Link to post
Share on other sites
I actuall did it like this:

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

But now i have a comma at the end of the string, how can i remove this?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.