IleNea
IleNea

Reputation: 609

Inverse format currency symbol php

So I am trying to inverse the value and the symbol that are being returned from:

 numfmt_format_currency($currencyFormatter, $value, $formatValue())

This code gives me:

 4$

And I want to inverse it like:

 $4

Not sure how to do it because the function must take all the parameters.. If anyone has some ideas I would appreciate it.

Upvotes: 1

Views: 304

Answers (2)

pmaldera
pmaldera

Reputation: 167

You could define your proper NumberFormat and set your own pattern, here is an exemple :

<?php

$formatter = new NumberFormatter('us_US',  NumberFormatter::CURRENCY);
$formatter->setPattern('¤#,##0.00');
echo numfmt_format_currency($formatter, 4, 'USD');

?>

Result :

$4.00

Upvotes: 5

Vidal
Vidal

Reputation: 2621

You can use number_format() instead:

print '$' . number_format($value,2,'.',',');

PHP Ref

Upvotes: 0

Related Questions