I need to display '150000.50' in Indian number format with the last zero intact.
I followed the following, but the solution Previous answer doesn't completely solve the issue. It removes the last 0 from the number which is required in my case.
1.
preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $num);
// Output: 1,50,000.5
// Expected output: 1,50,500.50
new NumberFormatter($locale = 'en_IN', NumberFormatter::DECIMAL); from Intl extension.
// Output: 1,50,000.5
// Expected output: 1,50,500.50
money_format
is now deprecated. If anyone can update preg_replace
function regex to preserve the trailing zero, it will be helpful.