PHP strtr() လုပ်ဆောင်ချက်
ဥပမာ
စာကြောင်းရှိ "ia" စာလုံးများကို "eo" ဖြင့် အစားထိုးပါ။
<?php
echo strtr("Hilla Warld","ia","eo");
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
strtr() function သည် string တစ်ခုရှိ အချို့သော စာလုံးများကို ဘာသာပြန်ပါသည်။
မှတ်ချက်- ဘောင်များမှ အတိုင်းအတာများနှင့် အလျားကွာခြားပါက၊ နှစ်ခုလုံးကို အတိုဆုံးအရှည်အဖြစ် ဖော်မတ်လုပ်မည်ဖြစ်သည်။
အထားအသို
strtr(string,from,to)
သို့မဟုတ်
strtr(string,array)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
string | Required. Specifies the string to translate |
from | Required (unless array is used). Specifies what characters to change |
to | Required (unless array is used). Specifies what characters to change into |
array | Required (unless to and from is used). An array containing what to change from as key, and what to change to as value |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ဘာသာပြန်ထားသော စာကြောင်းကို ပြန်ပေးသည်။ အခင်းအကျင်း ကန့်သတ်ဘောင်တွင် ဗလာစာကြောင်း ("") သော့တစ်ခုပါ ရှိလျှင် ၎င်းသည် FALSE သို့ ပြန်သွားမည်ဖြစ်သည်။ |
---|---|
PHP ဗားရှင်း- | 4+ |
နောက်ထပ် ဥပမာများ
ဥပမာ
"Hello world" ဟူသော စာတန်းကို "Hi earth" ဖြင့် အစားထိုးပါ။
<?php
$arr = array("Hello" => "Hi", "world" => "earth");
echo strtr("Hello world",$arr);
?>
❮ PHP String အကိုးအကား