PHP money_format for EURO

有些话、适合烂在心里 提交于 2019-12-06 20:07:53

问题


We can use following code for get $ mark and format money.

setlocale(LC_MONETARY, 'en_US.UTF-8');
$amount = money_format('%(#1n', $amount);

How to get euro symbol from php money_format?


回答1:


i think this will work

setlocale(LC_MONETARY, 'nl_NL.UTF-8');
$amount = money_format('%(#1n', 20);
echo $amount;



回答2:


Use this

setlocale(LC_MONETARY, 'nl_NL');
$amount = money_format('%(#1n', $amount);



回答3:


A quite old thread but if some google here That worked even on a local MAMP

setlocale(LC_MONETARY, 'de_DE');
echo money_format('€ %!n', 1.620.56);

// € 1.620.56 



回答4:


You can use the HTML entity

"&euro";

Directly in your code

$amount = money_format('%(#1n', $amount) .htmlentities('€');

EDIT

Or you can use the ! flag %(#!1n' so you code will looks like

$amount = money_format('%(#!1n', $amount) .htmlentities('€');

You can see the following post

  • PHP show money_format without currency text

Hope this would help




回答5:


Finally a Italy locale worked for me.

$amount = '1600.00';
setlocale(LC_MONETARY, 'it_IT.UTF-8');
$amount = money_format('%.2n', $amount);
echo str_replace('Eu','€',$amount);



回答6:


This is an old thread but I felt it worth sharing a relevant solution as the top answer doesn't provide an actual solution. I found this whilst searching for Spanish LC_monetary so if, like me, you end up here you know have an answer.

I use the following wrapped in a function with the advantage that it handles zeros nicely (see example in calculations ). I use this in my calculators for a slicker accounting layout. This example is Spain but you can use whichever Euro area you prefer:

setlocale(LC_MONETARY, "en_ES"); 
function C_S($iv) { 
    if(in_array($iv, array(' ','',0)) ){return'<i>&euro;</i>0.00';}
    else{return str_replace('EU','<i>&euro;</i>', money_format("%i", $iv));} 
} 

the italics are not necessary, I use them with css for alignment for finance style reports. Again, here for info.

to use:

echo C_S(1234);



回答7:


$price = 880000;
echo number_format($price, 2, ',', '.');

input => 880000

output => 880.000,00



来源:https://stackoverflow.com/questions/16519923/php-money-format-for-euro

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!