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 Quote 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] Quote 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? Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.