AndieB Posted April 13, 2006 Share Posted April 13, 2006 Hi all!If I have a variable, lets call it $number, and it contains the number 21500.Is there a function which can performe a thousand separator function, so the displayed result willbe 21 500?And even at next level, million separator?Thankful for anykind of help!--Andreas Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/ Share on other sites More sharing options...
AndyB Posted April 13, 2006 Share Posted April 13, 2006 [a href=\"http://ca3.php.net/manual/en/function.number-format.php\" target=\"_blank\"]number format function[/a] Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/#findComment-26695 Share on other sites More sharing options...
deadonarrival Posted April 13, 2006 Share Posted April 13, 2006 Simple usage.[code]$number = "1337357";$number = number_format($number);echo $number;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/#findComment-26738 Share on other sites More sharing options...
lansing Posted April 13, 2006 Share Posted April 13, 2006 Can this be used on the [i][b]decimal(6,2)[/b][/i] data type? Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/#findComment-26770 Share on other sites More sharing options...
Barand Posted April 13, 2006 Share Posted April 13, 2006 [code]$n = 12345.67;echo number_format ($n, 2);[/code]--> 12,345.67 Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/#findComment-26797 Share on other sites More sharing options...
lansing Posted April 14, 2006 Share Posted April 14, 2006 [!--quoteo(post=364618:date=Apr 13 2006, 05:52 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 13 2006, 05:52 PM) [snapback]364618[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]$n = 12345.67;echo number_format ($n, 2);[/code]--> 12,345.67[/quote]Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/#findComment-27006 Share on other sites More sharing options...
AndieB Posted April 16, 2006 Author Share Posted April 16, 2006 Follow-Up question:In Sweden we tend to use the , (comma) as a separator for decimals. I've noticed that PHP will not accept me doing a calculation using the comman (,) sign. (ie 30000 * 1,25), I must do this (30000 * 1.25).Is this something one can change or do I have to live with it?Thanks 4 any kind of help!--Andreas Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/#findComment-27409 Share on other sites More sharing options...
redbullmarky Posted April 16, 2006 Share Posted April 16, 2006 [!--quoteo(post=365241:date=Apr 16 2006, 08:34 AM:name=AndieB)--][div class=\'quotetop\']QUOTE(AndieB @ Apr 16 2006, 08:34 AM) [snapback]365241[/snapback][/div][div class=\'quotemain\'][!--quotec--]Follow-Up question:In Sweden we tend to use the , (comma) as a separator for decimals. I've noticed that PHP will not accept me doing a calculation using the comman (,) sign. (ie 30000 * 1,25), I must do this (30000 * 1.25).Is this something one can change or do I have to live with it?Thanks 4 any kind of help!--Andreas[/quote]as far as i know, you have to live with it, just like all us non-americans have to get used to spelling the word 'colour' without the 'u' :) Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/#findComment-27418 Share on other sites More sharing options...
Barand Posted April 16, 2006 Share Posted April 16, 2006 Have a look at [a href=\"http://www.php.net/setlocale\" target=\"_blank\"]http://www.php.net/setlocale[/a] Quote Link to comment https://forums.phpfreaks.com/topic/7335-thousand-separator/#findComment-27423 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.