How to format a dollar amount using PHP; money format; number_format

This will format a number into a dollar amount.

function money_format($amount) {
    return number_format($amount, 2, '.', ',');
}

Example:

$amount = 123456;
echo money_format($amount); // 123,456.00
Did this help you? Please let me know with a comment. Thank you
Posted .

1 comment (RSS)

  1. anonymous

    thanks my friend

Leave a comment