glenelkins Posted September 20, 2006 Share Posted September 20, 2006 Ok quick thingIf 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 Link to comment https://forums.phpfreaks.com/topic/21399-displaying-thousands-with-a-comma/ Share on other sites More sharing options...
zq29 Posted September 20, 2006 Share Posted September 20, 2006 [code]<?php$price = number_format($price,2,".",",");?>[/code] Link to comment https://forums.phpfreaks.com/topic/21399-displaying-thousands-with-a-comma/#findComment-95271 Share on other sites More sharing options...
glenelkins Posted September 20, 2006 Author Share Posted September 20, 2006 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? Link to comment https://forums.phpfreaks.com/topic/21399-displaying-thousands-with-a-comma/#findComment-95276 Share on other sites More sharing options...
wildteen88 Posted September 20, 2006 Share Posted September 20, 2006 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. Link to comment https://forums.phpfreaks.com/topic/21399-displaying-thousands-with-a-comma/#findComment-95290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.