PHP explode() လုပ်ဆောင်ချက်
ဥပမာ
လိုင်းတစ်ခုကို array တစ်ခုထဲသို့ ခွဲပါ-
<?php
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
explode() function သည် string တစ်ခုကို array တစ်ခုသို့ ခွဲပေးသည်။
မှတ်ချက်- "ခြားနားခြင်း" ဘောင်သည် ဗလာစာကြောင်းမဖြစ်ရပါ။
မှတ်ချက်- ဤလုပ်ဆောင်ချက်သည် binary-safe ဖြစ်သည်။
အထားအသို
explode(separator,string,limit)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
separator | Required. Specifies where to break the string |
string | Required. The string to split |
limit | Optional. Specifies the number of array elements to return. Possible values:
|
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | strings array တစ်ခုကို ပြန်ပေးသည်။ |
---|---|
PHP ဗားရှင်း- | 4+ |
ပြောင်းလဲမှုမှတ်တမ်း- | က န့်သတ်ကန့်သတ် ဘောင်ကို PHP 4.0.1 တွင် ထည့်သွင်းခဲ့ပြီး၊ အနှုတ် ကန့်သတ်ချက်များကို ပံ့ပိုးမှုအား PHP 5.1.0 တွင် ထည့်သွင်းခဲ့သည်။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
array ဒြပ်စင်များစွာကို ပြန်ပေးရန်အတွက် ကန့်သတ်ဘောင်ကို အသုံးပြုခြင်း-
<?php
$str = 'one,two,three,four';
// zero limit
print_r(explode(',',$str,0));
// positive limit
print_r(explode(',',$str,2));
// negative limit
print_r(explode(',',$str,-1));
?>
❮ PHP String အကိုးအကား