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

অপশনাল।ফরম্যাট করতে হলে স্ট্রিং এবং কিভাবে ফরম্যাট করতে হবে নির্ধারণ করুন。

সম্ভাব্য ফরম্যাট মানঃ

পূরণকর্ম ও সূচকঃ

  • =f - ফিল্ড (f) কে পূরণকর্ম করে ব্যবহার করুন (উদাহরণ: %=t 't' কে পূরণকর্ম করে ব্যবহার করুন)।ডিফল্ট পূরণকর্ম হল স্পেস ( )।
  • ^ - গ্রুপিং চার্যকে ব্যবহার করতে বন্ধ করুন。
  • + বা ( - পজিটিভ ও নেগেটিভ সংখ্যাকে কিভাবে দেখানো হবে।যদি '+' ব্যবহার করা হয়, তবে স্থানীয় সংস্থাপনা ব্যবহার করা হবে (+ ও - সাধারণত নেগেটিভ সংখ্যার আগে ব্যবহৃত হয়, পজিটিভ সংখ্যার আগে কোনো সংকেত নেই)।যদি '(' ব্যবহার করা হয়, তবে নেগেটিভ সংখ্যা সরুকিরপে থাকবে।ডিফল্ট '+' ব্যবহার করা হবে。
  • ! - আউটপুট স্ট্রিংয়ে মুদ্রাপদ ব্যবহার করতে বন্ধ করুন。
  • - "-" ব্যবহার করলে, সমস্ত ফিল্ড ডানদিকে সাজানো হবে।ডিফল্ট ডানদিকে সাজানো হয়。

ফিল্ড প্রস্থঃ

  • x - ফিল্ডের ন্যূনতম প্রস্থ (x) নির্ধারণ করুন।ডিফল্ট 0 হয়。
  • #x - সমূহের ডিজিটাল হোক্স সম্প্রসারিত হবে (x)।এটা ফরম্যাট আউটপুটকে একই স্তম্ভে সমানভাবে সাজানোর জন্য ব্যবহৃত হয়।যদি ডিজিটাল সংখ্যা বৃদ্ধি পায়, তবে এই নির্দেশনা অবহেলা করা হবে।
  • .x - Specifies the maximum number of digits to the right of the decimal point (x). If x is 0, the decimal point and the digits to the right will not be displayed. The default uses local settings.

Conversion character:

  • i - The number is formatted in the international currency format.
  • n - The number is formatted in the national currency format.
  • % - Returns the % 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)