0

lets say i have
$num1 = 0;
$num2 = 1.00;
$num3 = 1.2;

is there a php function that will convert int or double/float to usa dollar currency?
so the output should be
$num1 => 0.00;
$num2 => 1.00; //note this will stay same
$num3 => 1.20;

i found this function on google

setlocale(LC_MONETARY, 'en_US');
money_format($num3);

but it say its a "Call to undefined function money_format()"

Edited by hwoarang69

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by blocblue
1

According to the PHP docs, money_format is unsupported on Windows environments. Are you running Windows?

As an alternative, you could try number_format.

number_format(0, 2);    // 0.00
number_format(1.00, 2); // 1.00
number_format(1.2, 2);  // 1.20
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.