Price format Display

4 posts by 2 authors in: Forums > CMS Builder
Last Post: November 21, 2014   (RSS)

Hi

I have a "price" field in my property listings section.

I enter values in in the cmsb admin like 150000 which then displays on my website as 150,000 which is what I want, so far so good.

I display the price using the following code:-

<?php echo number_format($listing['price']) ?>

However I have some French pages which uses the same "price" field from the listings section.

I want to be able to display the "price" field on these pages like 150.000 (European format)

Is there a different syntax I can use which would display the "price" field in this European Format.

Your help would be appreciated.

Thanks

Andy

By claire - November 19, 2014

Hey Andy

You can use the same function with some extra parameters to get a different format, like so:

<?php echo number_format($listing['price'], 2, ',', '.');) ?>

This will format a number with 2 places after the decimal and a comma as the decimal separator and a period as the thousands separator, like this: 150.000,00

Here's the function reference if you want to play around with it: http://php.net/manual/en/function.number-format.php

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By claire - November 21, 2014

No, that looks fine. Sorry about the syntax error!

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/