2013-08-21 2 views
0

Я пытаюсь отобразить знак £ и запятые с в ряде показать валюту, но я не знаю, как, вот код, у меня есть, что эха это как 8999999 вместо £ 8.999.999PHP валюты дисплей

<div id="form"> 
<form action="index.php" method="post"> 

    <center> <input type="text" name="percent" id="percent" /> 
    <input type="submit" /> </center> 

</form> 
<center> 
<?php 
    $percent=$_POST['percent']; 
    $total = 8999999; 

    /*calculation for discounted price */ 

    $discount_value=$total/100*$percent; 

    $final_price = $total - $discount_value; 

    echo $final_price; 

?> 
</center> 
</div> 
+1

[number_format()] (http://www.php.net/manual/en/function.number-format.php) или [money_format()] (http://www.php.net/) manual/en/function.money-format.php) или [sprint()] (http://www.php.net/manual/en/function.sprintf.php) –

+0

Возможный дубликат [основная помощь php form (валюта) дисплей)] (http://stackoverflow.com/questions/345704/basic-php-form-help-currency-display) – hakre

ответ

0

echo '£'.number_format($final_price,2,",","."); попробовать

1

Вы можете использовать функцию money_format. Как вы можете видеть здесь http://php.net/manual/en/function.money-format.php вы можете форматировать номер в вашей валюты:

// let's print the international format for the en_US locale 
setlocale(LC_MONETARY, 'en_US'); 
echo money_format('%i', $number) . "\n"; 
// USD 1,234.56 
0

Это должно помочь вам.

<?php 
    echo "&pound".money_format('%.2n', $final_price); 
?> 

Проверить money_format на php.net

0

Я думаю, что это что вы искали:

echo '£'. number_format ($ final_price);

Смежные вопросы