PHP strcspn() လုပ်ဆောင်ချက်
ဥပမာ
"Hello world!" တွင်တွေ့ရသော စာလုံးအရေအတွက်ကို ပရင့်ထုတ်ပါ။ ဇာတ်ကောင် "w" ရှေ့မှာ
<?php
echo strcspn("Hello world!","w");
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
strcspn() လုပ်ဆောင်ချက်သည် သတ်မှတ်ထားသော စာလုံးများ၏ အစိတ်အပိုင်းကို မတွေ့ရှိမီ စာကြောင်းတစ်ခုတွင် တွေ့ရှိသည့် စာလုံးအရေအတွက် (အဖြူကွက်များ အပါအဝင်) ကို ပြန်ပေးသည်။
အကြံပြုချက်- သတ်မှတ်ထားသော စာလုံးစာရင်းမှ စာလုံးများသာ ပါဝင်သော string တွင်တွေ့ရှိရသော စာလုံးအရေအတွက်အတွက် strspn () လုပ်ဆောင်ချက်ကို အသုံးပြုပါ။
မှတ်ချက်- ဤလုပ်ဆောင်ချက်သည် binary-safe ဖြစ်သည်။
အထားအသို
strcspn(string,char,start,length)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
string | Required. Specifies the string to search |
char | Required. Specifies the characters to search for |
start | Optional. Specifies where in string to start |
length | Optional. Specifies the length of the string (how much of the string to search) |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | သတ်မှတ်ထားသော အက္ခရာများ၏ တစ်စိတ်တစ်ပိုင်းကို မတွေ့ရှိမီ စာကြောင်းတစ်ခုတွင် တွေ့ရသော စာလုံးအရေအတွက်ကို ပြန်ပေးသည်။ |
---|---|
PHP ဗားရှင်း- | 4+ |
ပြောင်းလဲမှုမှတ်တမ်း- | PHP 4.3 တွင် စတင်ခြင်း နှင့် အရှည် ဘောင်များကို ထည့်သွင်းထားသည်။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
"Hello world! ဇာတ်ကောင် "w" ရှေ့မှာ
<?php
echo strcspn("Hello world!","w",0,6); // The start position is 0 and the length of the search string is 6.
?>
❮ PHP String အကိုးအကား