DesComm Posted April 22, 2016 Report Share Posted April 22, 2016 Currently numbers are shown like 1234567 - How do you get formating to 1,234,567, I have tried to use php below results in a error. // english notation (default) $english_format_number = number_format($number); // 1,235 I was able to format Money with commas using the following in app.config.php now that formats $12,345.55 Config::Set('MONEY_FORMAT', '%i(#10n'); Quote Link to comment Share on other sites More sharing options...
web541 Posted April 22, 2016 Report Share Posted April 22, 2016 To format a number, the first one was correct, but I believe you were getting an error because you haven't specified what the $number variable is. Try this <?php $number = 123456789; $format = number_format($number); echo $format; ?> If that still doesn't work, then try doing it straight from a number <?php $format = number_format("123456789"); echo $format; ?> To format the money easily in phpVMS just use this: <?php echo FinanceData::formatMoney(floatval(Auth::$userinfo->totalpay)); ?> To get the pay for the currently logged in user, otherwise change Auth::$userinfo->totalpay to another variable depending on where you want to put it. Quote Link to comment Share on other sites More sharing options...
DesComm Posted April 23, 2016 Author Report Share Posted April 23, 2016 To format a number, the first one was correct, but I believe you were getting an error because you haven't specified what the $number variable is. Try this <?php $number = 123456789 $format = number_format($number); echo $format; ?> If that still doesn't work, then try doing it straight from a number <?php $format = number_format("123456789"); echo $format; ?> Neither of the above fixed the issue, numbers still did not have commas in them. Any other fixes?? Quote Link to comment Share on other sites More sharing options...
web541 Posted April 23, 2016 Report Share Posted April 23, 2016 Do you mind telling us where you want to put the code and what information you want to have formatted? Quote Link to comment Share on other sites More sharing options...
DesComm Posted April 23, 2016 Author Report Share Posted April 23, 2016 Do you mind telling us where you want to put the code and what information you want to have formatted? These were done in /core/app.config.php - we want this to apply to all numbers in phpvms. Weather it be logs, flights, hours all numbers should be shown with commas inserted. Quote Link to comment Share on other sites More sharing options...
web541 Posted April 23, 2016 Report Share Posted April 23, 2016 Hmmm, there is no setting to globally change all numbers to number_format() I don't think, so the best solution would be to change them manually. I guess you could keep fiddling in the config file, but it's not set to change anything in particular so it might not work. Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted April 23, 2016 Administrators Report Share Posted April 23, 2016 You could use the setlocale function and set the LC_NUMERIC category somewhere at the start of the script. -> http://php.net/manual/en/function.setlocale.php No guarantees on this as there is a lot of places in phpVMS thst use various types of numeric values including flight numbers and pilot id's. You will probably end up with things like => Flight # ABC1,234 - most likely you will need to just use number_format where you want your specific format. Quote Link to comment 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.