Hello

HOw do I format the output of my prices/numbers using number_format ()

In the code below I have the dynamic field from a recordset which shows the price. Currently the numbers are as such for example: 100000 and I would like them to be displayed as 100,000 or 1,000,000 etc

<?php echo $row_rs_search['prop_price']; ?>

Do I put the number_format() function here where the result is displayed?

So something like:

$price = $_POST[prop_price] number_format($price)<?php echo $row_rs_search['prop_price']; ?>

I suspect I might need the more advance version number_format (float $price [, int $decimals = 0] ?

Many thanks for the help

Try the following:

$price=number_format($price,2,'.',',');

That is perfect! Thank you :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.