Add commas as thousands separator and floating point dot in php -
i have this
$example = "1234567" $subtotal = number_format($example, 2, '.', '');
the return of $subtotal "1234567.00"
how modify definition of $subtotal, make "1,234,567.00"
below output 1,234,567.00
$example = "1234567"; $subtotal = number_format($example, 2, '.', ','); echo $subtotal;
syntax
string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
but advise use money_format formats number currency string
Comments
Post a Comment