PHP修剪值xxxx.xxxx到xxxx,xx

时间:2014-09-26 08:13:19

标签: php magento trim

我们一直在Magento支持的网站上进行一些配置,但我们的价格存在问题。

我们想要的是,当PHP获得一个值时,它需要以正确的方式修剪它以获得正确的显示。

示例:

输入:107.9400
产量:107,94

<?php echo nl2br ($_product->getmsrp())?><br><?php endif; ?>

http://i.imgur.com/eis1R4v.png

于:

enter image description here

第二张图片是在浏览器中以HTML格式编辑的,所以它还没有修复! 我们一直在寻找装饰但不幸的是我们找不到任何东西。我们对这种编程语言也很陌生......

提前致谢!

2 个答案:

答案 0 :(得分:3)

$number = number_format ($number , 2 , ',' , '.')

使用:

  

string number_format(float $ number,int $ decimals = 0,string   $ dec_point =&#34;。&#34; ,string $ thousands_sep =&#34;,&#34; )

请参阅http://php.net/manual/en/function.number-format.php

答案 1 :(得分:0)

您可以使用以下代码获取货币和两位小数格式的任何价格: -

  `Mage::helper('core')->currency($_product->getmsrp(),true,false);`