我正在尝试将字符串中的某些单词替换为对立面。
我试过了:
$input = "the big black cat likes the small white dog";
$array_oldwords = array("black","white","big","small");
$array_newwords = array("white","black","small","big");
$input = str_replace($array_oldwords,$array_newwords,$input);`
所需的输出是:
the small white cat likes the big black dog
但实际上是:
the big black cat likes the big black dog
如何实现这一目标?