Change your Display for Different Currency Formats

Last Updated on: May 16, 2026

Many international websites now need to display prices in several different local currencies. As a web developer, it does not matter if your visitors are using US dollars, Euros, UK Pounds or Japanese Yen; you will want the currency to display properly for all of them. One of the best ways for you to do this is to use the number_format() PHP function to convert the output to the correct format.

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

This will convert the value $total to the format $xx.yy and show two decimal places. This next example shows the use of the number_format() function to show a value in different currencies.

<?php
$number = 1234.56;
// Use English notation (default)
$english_format_number = number_format($number);
// 1,235
// Show it in French format
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56
$number = 1234.5678;
// And back to English without the thousand separator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
?>

It is worth knowing what the four arguments to number_format() do. The first is the number itself, the second is how many decimal places to show, the third is the character used for the decimal point, and the fourth is the thousands separator. Swapping those last two is exactly what moves you between English and French conventions in the example above.

All you need to do now is to add some code that will convert your prices based on the current exchange rate and then you can display them in any currency format that your customers desire. Just remember to change the currency sign to that of the local currencies, whether £, $ or €, before you upset someone.


Get notified of new posts:


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *