str_replace($search, $replace, $subject);
我对 $search 字符串和 $replace 字符串没有任何问题。
但是如何使用str_replace()
$search 字符串和 $replace 数组呢?
该str_replace()
文档提供了一个清晰的示例,如何使用数组(大小相等):
// 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
数组,而且“奇怪”:应该使用哪个数组值进行匹配?