PHP strist() လုပ်ဆောင်ချက်
ဥပမာ
"Hello world!" အတွင်းရှိ "ကမ္ဘာ" ၏ ပထမဆုံးပေါ်ပေါက်မှုကို ရှာပြီး ကျန်စာကြောင်းကို ပြန်ပေးပါ။
<?php
echo stristr("Hello world!","WORLD");
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
strist() လုပ်ဆောင်ချက်သည် အခြားသော string အတွင်းရှိ string တစ်ခု၏ ပထမဆုံး ဖြစ်ပေါ်မှုကို ရှာဖွေသည်။
မှတ်ချက်- ဤလုပ်ဆောင်ချက်သည် binary-safe ဖြစ်သည်။
မှတ်ချက်- ဤလုပ်ဆောင်ချက်သည် အကြီးအသေး အာရုံမခံပါ။ case-sensitive ရှာဖွေမှုတစ်ခုအတွက်၊ strstr() လုပ်ဆောင်ချက်ကို အသုံးပြုပါ။
အထားအသို
stristr(string,search,before_search)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
string | Required. Specifies the string to search |
search | Required. Specifies the string to search for. If this parameter is a number, it will search for the character matching the ASCII value of the number |
before_search | Optional. A boolean value whose default is "false". If set to "true", it returns the part of the string before the first occurrence of the search parameter. |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ရှာဖွေရန် စာကြောင်းကို ရှာမတွေ့ပါက ကျန်စာကြောင်း (ကိုက်ညီသည့်အချက်မှ) သို့မဟုတ် FALSE ကို ပြန်ပေးသည်။ |
---|---|
PHP ဗားရှင်း- | 4+ |
ပြောင်းလဲမှုမှတ်တမ်း- | before_search parameter ကို PHP 5.3 တွင် ထည့်ထားသည် ။ ဤလုပ်ဆောင်ချက်ကို PHP 4.3 တွင် binary-safe ပြုလုပ်ထားသည်။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
"o" ၏ ASCII တန်ဖိုးအတွက် စာကြောင်းတစ်ကြောင်းကို ရှာပြီး ကျန်စာကြောင်းကို ပြန်ပေးပါ။
<?php
echo stristr("Hello world!",111);
?>
ဥပမာ
"ကမ္ဘာ" ၏ပထမဆုံးမပေါ်ပေါက်မီ စာကြောင်း၏အစိတ်အပိုင်းကို ပြန်ပေးပါ။
<?php
echo stristr("Hello world!","WORLD",true);
?>
❮ PHP String အကိုးအကား