【发布时间】:2017-07-18 03:32:04
【问题描述】:
我有这个代码:
//This line is for the input that i've looped above my code, it's a URL
$textAr[$i] = str_replace("\r\n","", $textAr[$i]);
//This is for implode purposes
$finalArray = array($textAr[$i], $m1, $m2, $m3, $m4, $m5, $m6);
//When i echo this variable, $test, the URL is in the line along with the implode arrays
$test = implode($finalArray, "***");
echo $test."\n";
//This is for writing into my text file
fwrite($sitesTxt, implode($finalArray, "***")."\n");
我遇到了一种错误,在我输入 3 个 URL 后,第一个和第二个 URL 在我写入文件后有新行,但我输入的最后一个 URL 与内爆数组一致.我什至修剪了 $textArr,但我不断收到新行。
预期输出:
https://docs.google.com***false***false***false***false***false***false***
https://stackoverflow.com***false***false***false***false***false***false***
https://stackexchange.com***false***false***false***false***false***false***
我在 txt 文件中得到的输出:
https://docs.google.com
***false***false***false***false***false***false***
https://stackoverflow.com
***false***false***false***false***false***false***
https://stackexchange.com***false***false***false***false***false***false***
【问题讨论】:
-
请发布您的完整代码(包括循环、示例数据)
-
你能告诉我
$textArr[$i]是什么吗?你能呼应吗?或者只是给出示例数据 -
我的代码是垃圾。这是给菜鸟的。无论如何,我已经接受了 RichGold 的解决方案,它对我有用。谢谢!