LucasRolff
LucasRolff

Reputation: 1298

money_format, move the 'currency name'

I'm at the moment using the PHP money_format() function, and have money_format('%.0i', $row['price']) at the moment it outputs something like: DKK 199.900 - is there a way I can output it like 199.900 DKK instead?

Upvotes: 2

Views: 1564

Answers (4)

Jorge Y. C. Rodriguez
Jorge Y. C. Rodriguez

Reputation: 3449

Actually @sandeep was right, he just forgot to add the ! to remove the monetary symbol from the beginning.

setlocale(LC_MONETARY, 'da_DK');
$money_in_the_bank = 9333;
echo money_format('%!.0i DKK', $money_in_the_bank);

This will output:

9.333 DKK

Upvotes: 0

David
David

Reputation: 11

So the pattern money_format('%!.0i DKK', $price); could be a solution where ! will put off auto currency sign and it is added manually at the end

Upvotes: 0

Ingmar Boddington
Ingmar Boddington

Reputation: 3500

Use number_format instead (this is cross OS compatible too):

$value = number_format($value, [decimal places]).' DKK';

Upvotes: 3

sandeep
sandeep

Reputation: 2234

replace first argument of money_format to '%.0i DKK';

Upvotes: 1

Related Questions