In order to get a correct output (decimal point and two digits) I created a UDT number_from_text that uses PHP function number_format().
The tag is {number_from_text price="1234.56"}.
Code: Select all
$price = number_format($params['price'], 2, ',', '.');
echo $price;
Of course this tag can also be used for weight or any other decimal number.
Need 3 digits in stead of 2? A decimal point instead of comma? A space instead of a point to seperate thousands? Just change the parameters of number_format().
Frank
* The output is always with 2 digits, independent of the input in the text input field. So if you have a price of say €10, it does not matter whether you enter 10 or 10,0 or 10,00 - the output will always be 10,00.
It also doesn't matter whether in the input field you use a comma, a point or the decimal point of the number keys - they will all be recognized as decimal point.