php str_replace()字符串到数组错误
我对$search字符串和$replace字符串没有问题 但是如何将php str_replace()字符串到数组错误,php,arrays,Php,Arrays,我对$search字符串和$replace字符串没有问题 但是如何将str_replace()与$search string和$replace array一起使用?提供了一个清晰的示例,说明如何使用数组(大小相同): 使用$search作为字符串和$replaces作为数组是不可能的,而且“奇怪”:应该使用哪个数组值进行匹配?什么意思$search string和$replace array??谢谢,我明白你的意思了 str_replace($search, $replace, $subject
str_replace()
与$search string和$replace array一起使用?提供了一个清晰的示例,说明如何使用数组(大小相同):
使用
$search
作为字符串和$replaces
作为数组是不可能的,而且“奇怪”:应该使用哪个数组值进行匹配?什么意思$search string和$replace array?
?谢谢,我明白你的意思了
str_replace($search, $replace, $subject);
// 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);