0
你好,如何阅读使用PHP和TXT文件替换数组? 我想读的文件是这样的:如何阅读文本文件和翻译fild
||Search||,||s||---||Images||,||i||
这是我的PHP代码:
$f = fopen("test.txt", "r");
$image= "Imgaes";
// Read line by line until end of file
while (!feof($f)) {
// Make an array using comma as delimiter
// $arrM = explode("---",fgets($f));
$arr = explode("||---||",fgets($f));
// Write links (get the data in the array)
$num = 1;
while($num <= 30) {
list($eng,$fa) = explode("||,||", $arr[$num]);
foreach($html->find('html') as $full) {
$all = $full->innertext;
}
$fe = str_replace($eng,$fa,$all);
$num = $num+1;
}
echo $fe;
}
fclose($f);
但这不工作:(!!!
“this does not work”is not a valid explanation for your problem。给我们提供错误信息,结果你g et,以及预期的结果。 – Jocelyn 2012-07-28 15:14:28
不知道问题,但这看起来不正确:$ image =“Imgaes”; – 2012-07-28 15:20:45
没有这个$ image只是测试我想用简单的html圆顶解析页面,并用这个文本文件翻译所有单词 – 2012-07-28 15:23:17