[英]Update txt file with file_get_content
我有以下代码:
$fisier = file_get_contents('urlproxy'); // Read the file with the proxy list
$linii = explode("\n", $fisier); // Get each proxy
$fisier = fopen("bune.txt", "a"); // Here we will write the good ones
我每次运行脚本时都需要它仅使用新代理重写 txt 文件。
有人能帮我吗?
您正在使用带有'a'
模式的fopen
。 根据PHP 文档:
'a' 只开放写; 将文件指针放在文件末尾。 如果该文件不存在,请尝试创建它。 在这种模式下, fseek() 不起作用,写入总是附加的。
所以,你需要使用'w'
模式。 像这样:
$fisier = fopen("bune.txt", "w");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.