PHP - string to money conversion
I'm开发者_如何转开发 trying to convert a string into money format using this function, and trying to create something like this :
350000000
to
350.000.000,00
All my attempts failed so far, being this the last one :
setlocale(LC_MONETARY, 'pt_PT.UTF-8@euro');
echo money_format('%.2n', $preco);
Any help would be appreciated. Cheers!
you can use number_format() like this:
$number = 350000000;
$money_number = number_format($number,2,',','.');
Maybe you need to compile locale definition files for Portuguese, it should go something like:
localedef -ci pt_PT -f utf-8 pt_PT
精彩评论