PHP strncmp() လုပ်ဆောင်ချက်
ဥပမာ
စာကြောင်းနှစ်ကြောင်း နှိုင်းယှဉ်ပါ (စာလုံးအသေး-အကဲဆတ်သည်--
<?php
echo strncmp("Hello world!","Hello earth!",6);
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
strncmp() function သည် string နှစ်ခုကို နှိုင်းယှဉ်သည်။
မှတ်ချက်- strncmp() သည် binary-safe ဖြစ်ပြီး case-sensitive ဖြစ်သည်။
အကြံပြုချက်- ဤလုပ်ဆောင်ချက်သည် strcmp() အရှည်ကန့်သတ်ချက်မရှိမှလွဲ၍ ဤလုပ်ဆောင်ချက်သည် strcmp() လုပ်ဆောင်ချက်နှင့် ဆင်တူသည်။
အထားအသို
strncmp(string1,string2,length)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare |
string2 | Required. Specifies the second string to compare |
length | Required. Specify the number of characters from each string to be used in the comparison |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ဤလုပ်ဆောင်ချက်သည် ပြန်တက်လာသည်-
|
---|---|
PHP ဗားရှင်း- | 4+ |
နောက်ထပ် ဥပမာများ
ဥပမာ
စာကြောင်းနှစ်ခုကို နှိုင်းယှဉ်ပါ (စာလုံးအသေး အာရုံခံ = Hello နှင့် hELLo သည် တူညီမည်မဟုတ်ပါ)။
<?php
echo strncmp("Hello","Hello",6);
echo "<br>";
echo strncmp("Hello","hELLo",6);
?>
❮ PHP String အကိုးအကား