PHP str_pad() လုပ်ဆောင်ချက်
ဥပမာ
စာလုံး 20 အရှည်အသစ်သို့ စာကြောင်း၏ညာဘက်ခြမ်းသို့ pad ပါ-
<?php
$str = "Hello World";
echo str_pad($str,20,".");
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
str_pad() လုပ်ဆောင်ချက်သည် ကြိုးတစ်ချောင်းကို အရှည်အသစ်တစ်ခုအဖြစ် pads ပေးသည်။
အထားအသို
str_pad(string,length,pad_string,pad_type)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
string | Required. Specifies the string to pad |
length | Required. Specifies the new string length. If this value is less than the original length of the string, nothing will be done |
pad_string | Optional. Specifies the string to use for padding. Default is whitespace |
pad_type | Optional. Specifies what side to pad the string. Possible values:
|
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | padded string ကို ပြန်ပေးသည်။ |
---|---|
PHP ဗားရှင်း- | 4.0.1+ |
နောက်ထပ် ဥပမာများ
ဥပမာ
စာကြောင်း၏ဘယ်ဘက်ခြမ်းတွင် pad ပါ-
<?php
$str = "Hello World";
echo str_pad($str,20,".",STR_PAD_LEFT);
?>
ဥပမာ
ကြိုး၏နှစ်ဖက်စလုံးသို့ Pad
<?php
$str = "Hello World";
echo str_pad($str,20,".:",STR_PAD_BOTH);
?>
❮ PHP String အကိုးအကား