Skip to content
Advertisement

What is the JS equivalent to the PHP function number_format?

PHP Function:

function formatNumberForDisplay($number, $decimal=0, $decimalSeperator='.', $numberSeperator=',')
{
     return number_format($number, $decimal, $decimalSeperator, $numberSeperator);
}

Can anybody suggest to me the equivalent functionality in jQuery/JavaScript?

Advertisement

Answer

is this what you’d like to get?

yourFloatVarHere.toFixed(2);

voilĂ .

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement