Hello

I have some fields that result in a computed field result.

Currently, the result looks like "308219.17808219"

Where do i change the settings so results will look like "308, 219.17 "?

Thanks

L

Comments

marcvangend’s picture

If you really want to move the decimal, you would have to divide or multiply by 10, 100, 1000 etc. But I think you mean you want to group the thousands, right? You can use the number_format function for that: http://www.php.net/manual/en/function.number-format.php. In your case, you could use

$number = 308219.17808219;
$formatted_number = number_format($number, 2, '.', ',');
linuxpimp’s picture

Thank you Marc

Please excuse my next question:

Where would be the correct place/file to add the PHP code you kindly provided?

Thanks

L

marcvangend’s picture

I'm not a computed field expert, but looking at http://drupal.org/node/149225 I would say:
Calculate the value in the 'Computed Code' field (you probably already did that) and place this in the Display Format field:

$display = number_format($node_field_item['value'], 2, '.', ',');

Let me know if it works.

linuxpimp’s picture

Thank you!

I had to remove the and tags and it did exactly what i required.

Much appreciated

L