» tagged pages
» logout
PHP
Return to PHP Code Snippets

Formating monetary values

Tags Applied to this Entry

1 person has tagged this page:
Formating monetary values in euro



$number = 1234.567;


// First method
echo sprintf('%.2f €', $number); // 1234.57 €


// Second method
echo number_format($number, 2, ',', ' ') . ' €'; // 1 234,57 €


// Third method
setlocale(LC_MONETARY, 'en_US');
echo money_format('%n', $number); // $1,234.57

setlocale(LC_MONETARY, 'fr_FR');
echo money_format('%n', $number); // 1 234,57 Eu
echo money_format('%!n €', $number); // 1 234,57 €

?>


Retour à la source: Formating monetary values
Username:
Password:
(or Cancel)