PHP money_format() ফাংশন
উদাহরণ
en_US আন্তর্জাতিক ফরম্যাটঃ
<?php $number = 1234.56; setlocale(LC_MONETARY,"en_US"); echo money_format("The price is %i", $number); ?>
The output of the above code:
The price is USD 1,234.56
বিবরণ ও ব্যবহার
money_format() ফাংশন ফরম্যাট করা মুদ্রাস্ফুট স্ট্রিং ফেরত দেয়。
এই ফাংশনটি মূল স্ট্রিংয়ের % স্থানে একটি ফরম্যাট করা সংখ্যা প্রবর্তন করে。
Note:money_format() ফাংশন Windows প্ল্যাটফর্মে কাজ করতে পারে না。
সুঝাওয়াএই ফাংশনটি সাধারণত setlocale() ফাংশন একসঙ্গে ব্যবহার করুন。
সুঝাওয়াযদি সব সম্ভাব্য ভাষা কোডগুলি দেখতে হয়, তবে আমাদেরভাষা কোড সংক্ষিপ্ত বিবরণ।
সিন্ট্যাক্স
money_format(string,number)
পারামিটার | বর্ণনা |
---|---|
string |
অপশনাল।ফরম্যাট করতে হলে স্ট্রিং এবং কিভাবে ফরম্যাট করতে হবে নির্ধারণ করুন。 সম্ভাব্য ফরম্যাট মানঃ পূরণকর্ম ও সূচকঃ
ফিল্ড প্রস্থঃ
Conversion character:
Note:If multiple format values are used, they must appear in the order listed above. Note:This function is affected by the local settings. |
number | Required. The number inserted into the position of the % symbol in the formatted string. |
Technical Details
Return value: |
Returns the formatted string. Characters before and after the formatted string will remain unchanged and returned. Non-numeric numbers will return NULL and generate E_WARNING. |
PHP Version: | 4.3.0+ |
More Examples
Example 1
International format with 2 decimal places (Germany):
<?php $number = 1234.56; setlocale(LC_MONETARY,"de_DE"); echo money_format("%.2n", $number); ?>
The output of the above code:
1 234,56 EUR
Example 2
Negative number, with () indicating the negative number in the US international format, right precision is 2, and "*" is the fill character:
<?php $number = -1234.5672; echo money_format("%=*(#10.2n",$number); ?>
The output of the above code:
(******1234.57)