-1
str_replace($search, $replace, $subject);
我沒有問題,$搜索字符串和$替換字符串。php str_replace()字符串到數組錯誤
但是,我怎樣才能使用str_replace()
與$搜索字符串和$替換數組?
str_replace($search, $replace, $subject);
我沒有問題,$搜索字符串和$替換字符串。php str_replace()字符串到數組錯誤
但是,我怎樣才能使用str_replace()
與$搜索字符串和$替換數組?
的str_replace()
documentation提供一個明顯的例子如何使用(大小相等的)陣列:
// Provides: You should eat pizza, beer, and ice cream every day
$phrase = "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits", "vegetables", "fiber");
$yummy = array("pizza", "beer", "ice cream");
$newphrase = str_replace($healthy, $yummy, $phrase);
使用$search
作爲字符串和$replaces
作爲數組是不可能的,「怪異」:哪個數組值應該是用於比賽?
謝謝,我明白你的意思 – vzhen
你是什麼意思'$ search string和$ replace array?'? –