Php str_将file.txt中的字符串替换为另一个file.txt

Php str_将file.txt中的字符串替换为另一个file.txt,php,string,replace,str-replace,Php,String,Replace,Str Replace,我想用replaceword.txt文件替换searchword.txt文件中的一些字符串,但是用我的php代码它只能替换前两个字符串,我想替换文件中的所有字符串 以下是我的php代码: $txt_s = file_get_contents("searchword.txt"); $txt_s = explode(";", $txt_s); $txt_r = file_get_contents("replaceword.txt"); $txt_r = explode(";", $txt_r); $

我想用replaceword.txt文件替换searchword.txt文件中的一些字符串,但是用我的php代码它只能替换前两个字符串,我想替换文件中的所有字符串

以下是我的php代码:

$txt_s = file_get_contents("searchword.txt");
$txt_s = explode(";", $txt_s);
$txt_r = file_get_contents("replaceword.txt");
$txt_r = explode(";", $txt_r);
$term = str_replace($txt_s, $txt_r, $last_tmp_);
下面是我的searchword.txt文件的外观:

hello; modern; corn; banana; apple;
goodbye; fashionable; popcorn; monkey; sweet;
以下是我的replaceword.txt文件的外观:

hello; modern; corn; banana; apple;
goodbye; fashionable; popcorn; monkey; sweet;

如何替换所有字符串,而不仅仅是前两个字符串?或者可能有任何不同的方法,请让我知道。

例如,您必须使用

使用:


我测试了你的代码,它在我这边运行得很好。请尝试
str\u ireplace
查找不区分大小写的字符。看见