I have a database where I need to store the price of items. Now when I get the values from the database, I would like commas added for the thousand value e.g convert 19000 to 19,000.
<?php echo $row['pprice'];?>
How can I change the format?
You can try using this.
echo number_format($row['pprice']);
Not sure if its correct but wont hurt to try and see if it works.
Or create a new variable for the $row['pprice']
so like this.
$commaPrice = $row['pprice'];
echo number_format($commaPrice);
$newNumber = number_format($number);
I suggest to use money_format:
$number = 1234.56;
setlocale(LC_MONETARY, 'it_IT.UTF8');
echo money_format('%i', $number) . "
";
Note that you need to specify your current locale. If you want to use different locales than yours, you must build them install them on the operating system.