开发者

PHP number format 2 decimal places [duplicate]

开发者 https://www.devze.com 2023-04-04 01:32 出处:网络
This question already开发者_如何学编程 has answers here: Closed 11 years ago. Possible Duplicate:
This question already开发者_如何学编程 has answers here: Closed 11 years ago.

Possible Duplicate:

PHP number format

The following code out puts a figure for shipping cost based on a currency conversion that happens elsehwere, but it outputs with many decimal places. Can I alter something here that will produce a number with just 2 decimal places?

if(isset($_POST['ShippingMethod'])){
            $order['data']  .= "\r\n ========== Shipping Cost ========== \r\n\r";
            $order['data'] .="\r\n Shipping Method Cost: ". $_SESSION['currency_symbol'].$_POST['ShippingMethod']. " \r\n";
            $form['price']['shipping'] +=$_POST['ShippingMethod'];
    }   


have a look at http://php.net/number_format and if its related to currency, check out http://php.net/manual/en/function.money-format.php

0

精彩评论

暂无评论...
验证码 换一张
取 消