PHP strpos() လုပ်ဆောင်ချက်
ဥပမာ
string အတွင်းရှိ "php" ၏ပထမဆုံးဖြစ်ပျက်မှုအနေအထားကိုရှာပါ-
<?php
echo strpos("I love php, I love php too!","php");
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
strpos() လုပ်ဆောင်ချက်သည် အခြားသော string အတွင်းရှိ string တစ်ခု၏ ပထမဆုံး ဖြစ်ပေါ်မှု အနေအထားကို ရှာဖွေသည်။
မှတ်ချက်- strpos() လုပ်ဆောင်ချက်သည် case-sensitive ဖြစ်သည်။
မှတ်ချက်- ဤလုပ်ဆောင်ချက်သည် binary-safe ဖြစ်သည်။
ဆက်စပ်လုပ်ဆောင်ချက်များ-
- strrpos() - အခြား string အတွင်းရှိ စာကြောင်းတစ်ခု၏ နောက်ဆုံးဖြစ်ပေါ်မှု အနေအထားကို ရှာပါ
- stripos() - အခြား string အတွင်းရှိ string တစ်ခု၏ ပထမဆုံး ပေါ်ပေါက်မှု အနေအထားကို ရှာပါ ( case-insensitive )
- strripos() - အခြား string အတွင်းရှိ စာကြောင်းတစ်ခု၏ နောက်ဆုံးဖြစ်ပျက်မှု အနေအထားကို ရှာပါ (စာလုံးအသေးမပါသော)
အထားအသို
strpos(string,find,start)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
string | Required. Specifies the string to search |
find | Required. Specifies the string to find |
start | Optional. Specifies where to begin the search. If start is a negative number, it counts from the end of the string. |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | အခြားစာကြောင်းတစ်ခုအတွင်းရှိ စာကြောင်းတစ်ခု၏ ပထမဆုံးဖြစ်ပေါ်မှု အနေအထားကို ပြန်ပေးသည်၊ သို့မဟုတ် စာကြောင်းကို ရှာမတွေ့ပါက FALSE ပြန်ပေးသည်။ မှတ်ချက်- ကြိုးတန်းရာထူးများသည် 0 မှစတင်သည်၊ 1 မဟုတ်ပါ။ |
---|---|
PHP ဗားရှင်း- | 4+ |
ပြောင်းလဲမှုမှတ်တမ်း- | PHP 7.1.0 - စတင်မှုဘောင် သည် အနှုတ်နံပါတ်တစ်ခု ဖြစ်နိုင်သည်။ |
❮ PHP String အကိုးအကား