从文件替换文本我想多维数组中搜索和.txt文件查找和使用多维数组PHP
$array = [[0] => Array (
[Advertisement and Printing] => 6
)
[1] => Array (
[Advertising Agencies] => 7
)
[2] => Array (
[Advertising Materials] => 8
)
[3] => Array (
[Airport Ads] => 9
)]
...
等替换文本的价值...
.txt文件内容
Advertisement and Printing -> Advertising Materials
Health Care -> Medical Laboratory
Business Services -> ISO Consultants
Packaging -> Bindings and Laminations
在上述例子中,以我想替换数组值的字符串,例如 广告和Printi纳克 - >广告材料到6 - > 8
$fileContents = file_get_contents("theFile.txt");
$search = $array;
$replace = array(); // Not sure about the replace
$newContents = str_replace($search, $replace, $fileContents);
$handle = fopen("theFile.txt","w");
fwrite($handle, $newContents);
fclose($handle);
发布最终预期结果 – RomanPerekhrest
任何尝试???? – AbraCadaver