我想在文本文件中记录下载
有人来到我的网站并下载了一些东西,它会在文本文件中添加一个新行(如果尚未增加或增加当前文件).
我试过了
$filename = 'a.txt';
$lines = file($filename);
$linea = array();
foreach ($lines as $line)
{
$linea[] = explode("|",$line);
}
$linea[0][1] ++;
$a = $linea[0][0] . "|" . $linea[0][1];
file_put_contents($filename, $a);
Run Code Online (Sandbox Code Playgroud)
但它总是增加1以上
文本文件格式是
name|download_count
Run Code Online (Sandbox Code Playgroud) 我有一个带有一些值的数组
$array = array("Bob","jim","frank","pat");
Run Code Online (Sandbox Code Playgroud)
我从简单的html dom中得到了一些scrape代码
$html = file_get_html('http://somesite.com?search=name');
//itteration and so on
Run Code Online (Sandbox Code Playgroud)
我希望能够一次一个地给出url数组中的值,所以它会用search = bob抓取url然后转到search = jim等等
我尝试将file_get_html与itterations一起放在循环中,然后使用
foreach($array as $arrays){
$html = file_get_html('http://somesite.com?search=$arrays');
//more code
}
Run Code Online (Sandbox Code Playgroud)
但这不会起作用,无论如何要做到这一点?
php ×2