I have this code:
require("class.XMLHttpRequest.php");
function hot($news){
$url="https://localhost/search.aspx?search=".$news."";
$ajax=new XMLHttpRequest();
$ajax->setRequestHeader("Cookie","Cookie: host");
$ajax->open("GET",$url,true);
$ajax->send(null);
if($ajax->status==200){
$rHeader=$ajax->getResponseHeader("Set-Cookie");
if(substr_count($rHeader, "Present!")>0) { return true; }
}else{ return false; }
}
$celebrities = array('britney','gaga','carol');
$filename = 'result.txt';
$handle = fopen($filename, 'a');
foreach($celebrities as $celebrity)
{
if(hot($celebrity)) { fwrite($handle, "{$celebrity}\r\n"); };
}
fclose($handle);
And instead of
$celebrities = array('britney','gaga','carol');
$filename = 'result.txt';
$handle = fopen($filename, 'a');
foreach($celebrities as $celebrity)
{
if(hot($celebrity)) { fwrite($handle, "{$celebrity}\r\n"); };
}
fclose($handle);
I want to implement
$read_file = fopen('array.txt', 'r');
$write_file = fopen('result.txt', 'a');
while(!feof($read_file))
{
$celebrity = fgets($read_file);
if(hot($celebrity)) { fwrite($handle, "{$celebrity}\r\n"); }
}
fclose($write_file);
fclose($read_file);
now the result.txt doesnt gets written anymore, where do i go wrong? the script should read an array from a file, process the function hot and then write each reasults in a new line in result.txt thanks in advance!