Can't get number_format() to work
mkoskenk - February 23, 2009 - 17:31
| Project: | Computed Field |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hi!
I'm trying to display floating point numbers (money, that is) with two decimals with no luck. All trailing decimal zeros get cut off. Is there any way to work around this? Other number formatting functions such as round() or ceil() work with no probs.
Sample:
$sum = $node->field_t1_pieces[0]['value'] * $node->field_t1_price[0]['value'];
$node_field[0]['value'] = number_format($sum,2);Cheers,
Mikko

#1
I suspect that's the fault of having the incorrect field type. Make sure you defined the field as a decimal, not an integer.
Closing anyway because 5.x isn't supported anymore. You'll have to reproduce it in 6.x to re-open this.