lindm Posted September 28, 2008 Share Posted September 28, 2008 I have a price of code that transforms a string as follows: 1. Removes blanks 2. Rounds the number 3. Adds blanks again I get a strange output when trying to apply the code the negative numbers. When a user for instance enters - 1 000 000 or -10 000 000 into the outcome is -100 000. Code: function rrab($string) {$string2 = str_replace(' ', '', $string); $string3 = round($string2); $string4 = number_format($string3, 0, ',', ' '); return $string4;} Quote Link to comment https://forums.phpfreaks.com/topic/126141-solved-error-in-number-format-code/ 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.