tags:

views:

61

answers:

3

Hi,

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!

+1  A: 

Pfft. Too much magic in money_format() for my tastes. Try number_format() instead: http://php.net/manual/en/function.number-format.php

hollsk
+2  A: 

you can use number_format() like this:

$number = 350000000;
$money_number = number_format($number,2,',','.');
jigfox
+1  A: 

Maybe you need to compile locale definition files for Portuguese, it should go something like:

localedef -ci pt_PT -f utf-8 pt_PT
draganHR