PHP number_format() လုပ်ဆောင်ချက်
ဥပမာ
နံပါတ်များဖော်မတ်-
<?php
echo number_format("1000000")."<br>";
echo number_format("1000000",2)."<br>";
echo number_format("1000000",2,",",".");
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
number_format() လုပ်ဆောင်ချက်သည် ထောင်ပေါင်းများစွာ အုပ်စုဖွဲ့ထားသော နံပါတ်တစ်ခုကို ဖော်မတ်ပေးသည်။
မှတ်ချက် ။
အထားအသို
number_format(number,decimals,decimalpoint,separator)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
number | Required. The number to be formatted. If no other parameters are set, the number will be formatted without decimals and with comma (,) as the thousands separator. |
decimals | Optional. Specifies how many decimals. If this parameter is set, the number will be formatted with a dot (.) as decimal point |
decimalpoint | Optional. Specifies what string to use for decimal point |
separator | Optional. Specifies what string to use for thousands separator. Only the first character of separator is used. For example, "xxx" will give the same output as "x" Note: If this parameter is given, all other parameters are required as well |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ဖော်မတ်လုပ်ထားသော နံပါတ်ကို ပြန်ပေးသည်။ |
---|---|
PHP ဗားရှင်း- | 4+ |
ပြောင်းလဲမှုမှတ်တမ်း- | PHP 5.4 အရ၊ ဤလုပ်ဆောင်ချက်သည် parameters decimalpoint နှင့် separator တွင် bytes များစွာကို ပံ့ပိုးပေးသည် ။ ခွဲထွက်တစ်ခုစီ၏ ပထမဘိုက်ကိုသာ ဗားရှင်းအဟောင်းများတွင် အသုံးပြုခဲ့သည်။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
သင်သည် စျေးနှုန်းကို ပြန်ပေးလိုသည်- ကန့်သတ်ချက်တစ်ခုသည် နံပါတ်ကို ပတ်သွားလိမ့်မည် (၎င်းကို ဒဿမများမပါဘဲ ဖော်မတ်လုပ်မည်)။ ကန့်သတ်ချက်နှစ်ခုသည် သင်လိုချင်သောရလဒ်ကို ပေးသင့်သည်-
<?php
$num = 1999.9;
$formattedNum = number_format($num)."<br>";
echo $formattedNum;
$formattedNum = number_format($num, 2);
echo $formattedNum;
?>
❮ PHP String အကိုးအကား