Article

Replacing money_format()

Remove money_format() safely: lifecycle, modern replacements, and migration examples for legacy PHP apps.

money_format() formatted a number as a currency string using locale-aware strfmon-style patterns. It was never available on Windows builds of PHP.

Lifecycle (php.net)

  • Deprecated: Deprecated as of PHP 7.4.0
  • Removed: PHP 8.0.0

Modern replacement

Use NumberFormatter (intl) or a well-tested money library. Do not reimplement currency rules with number_format alone if you need locale-correct symbols and separators.

Migration example

# LEGACY — money_format()
setlocale(LC_MONETARY, 'en_US.UTF-8');
echo money_format('%.2n', $amount);

# MODERN
$fmt = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
echo $fmt->formatCurrency($amount, 'USD');

Scan before cutover

Search the tree for money_format() and paste samples into the PHP Version Compatibility Checker and PHP Deprecated Checker.

Related tools

Related reading