PHP str_word_count() လုပ်ဆောင်ချက်
ဥပမာ
"Hello World!" ဟူသော စာကြောင်းတွင် တွေ့ရသော စကားလုံးအရေအတွက်ကို ရေတွက်ပါ-
<?php
echo str_word_count("Hello world!");
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
str_word_count() လုပ်ဆောင်ချက်သည် စာကြောင်းတစ်ခုရှိ စကားလုံးအရေအတွက်ကို ရေတွက်သည်။
အထားအသို
str_word_count(string,return,char)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
string | Required. Specifies the string to check |
return | Optional. Specifies the return value of the str_word_count() function. Possible values:
|
char | Optional. Specifies special characters to be considered as words. |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ရွေးချယ်ထားသော ကန့ ် သတ် ချက်အပေါ်မူတည်၍ နံပါတ်တစ်ခု သို့မဟုတ် အခင်းတစ်ခုအား ပြန်ပေးသည်။ |
---|---|
PHP ဗားရှင်း- | 4.3.0+ |
ပြောင်းလဲမှုမှတ်တမ်း- | char parameter ကို PHP 5.1 တွင် ထည့်သွင်းခဲ့သည် ။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
string မှ စကားလုံးများဖြင့် array တစ်ခုကို ပြန်ပေးသည်-
<?php
print_r(str_word_count("Hello world!",1));
?>
ဥပမာ
သော့သည် စာကြောင်းရှိ စကားလုံး၏ အနေအထားဖြစ်သည့် array တစ်ခုကို ပြန်ပေးကာ တန်ဖိုးသည် တကယ့်စကားလုံးဖြစ်သည်-
<?php
print_r(str_word_count("Hello world!",2));
?>
ဥပမာ
char parameter မပါဘဲ၊
<?php
print_r(str_word_count("Hello world & good morning!",1));
print_r(str_word_count("Hello world & good morning!",1,"&"));
?>
❮ PHP String အကိုးအကား