preg_replace_callback_array()
function သည် callback function ၏ပြန်လည်နေရာချထားခြင်းဖြင့်ပုံမှန်ဖော်ပြချက်ပွဲများဖြင့်အစားထိုးထားသည့် strings သို့မဟုတ် strings ၏ strings သို့မဟုတ် strings array တစ်ခုသို့ပြန်ပို့သည်။
မှတ်စု: string တစ်ခုစီအတွက် function ကိုပေးထားသောအမိန့်တွင်ပုံစံကိုအကဲဖြတ်သည်။ string ပေါ်ရှိပထမဆုံးပုံစံကိုအကဲဖြတ်ခြင်း၏ရလဒ်ကိုဒုတိယပုံစံအတွက် input string ကိုအသုံးပြုလိမ့်မည်။ ၎င်းသည်မမျှော်လင့်သောအပြုအမူကိုဖြစ်ပေါ်စေသည်။
ဝါကျတစ်ခုတွင်စာလုံးတစ်လုံးစီသို့မဟုတ်နံပါတ်များသည်စာလုံးမည်မျှရှိကြောင်းပြပါ။
<? PHP function ceptletters ( $ ကိုက်ညီ ) { $ matches [ 0 ] ။ '[' ။ strlen ( $ ကိုက်ညီ [ 0 ] ) ။ 'letter]' ' ; } function countigits ( $ ကိုက်ညီ ) { $ matches [ 0 ] ။ '[' ။ strlen ( $ ကိုက်ညီ [ 0 ] ) ။ 'ဂဏန်း " ; } $ input = "တစ်နှစ်အတွက် 365 ရက်။ " ; $ ပုံစံများ = [ '/ \ b [az] + \ b / i' => 'countletters' , '/ \ ခ [0-9] + \ b /' => 'MDIGITITIS' ] ; $ ရလဒ် = preg_replace_callback_array ( $ ပုံစံများ , $ input ) ; ECHO $ ရလဒ် , >
သင်ကိုယ်တိုင်စမ်းကြည့်ပါ
ဤဥပမာသည်ပုံစံသည်နောက်ဆက်တွဲအကဲဖြတ်မှုတွင်မမျှော်လင့်သောအကျိုးသက်ရောက်မှုများကိုဖော်ပြသည်။ ပထမ ဦး စွာ ceptletters အစားထိုး "[4 letter]" [4 letter] "ပြီးနောက်" [4 letter] "add လိမ့်မယ်။ အစားထိုးလုပ်ဆောင်ပြီးနောက် Metterdigits Replacements သည် "4" တွင် "4" တွင် "4" တွင် "4" နှင့်ထပ်ပေါင်းထည့်လိမ့်မည် "[1digit]"
<? PHP function ceptletters ( $ ကိုက်ညီ ) { $ matches [ 0 ] ။ '[' ။ strlen ( $ ကိုက်ညီ [ 0 ] ) ။ 'letter]' ' ; } function countigits ( $ ကိုက်ညီ ) { $ matches [ 0 ] ။ '[' ။ strlen ( $ ကိုက်ညီ [ 0 ] ) ။ 'ဂဏန်း " ; } $ input = "365 ရက်" ; $ ပုံစံများ = [ '/ [AZ] + / I' / i '/ i' => 'countletters' , '/ [0-9] + /' / ' => ' MDIGITIS ' ] ; $ ရလဒ် = preg_replace_callback_array ( $ ပုံစံများ , $ input ) ; ECHO $ ရလဒ် , >
သင်ကိုယ်တိုင်စမ်းကြည့်ပါ