i have the following code:
which uses an array to write the result to file
i want to create another array to read the celebities aray from another file
<?php
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 i would like to load the $celebrities array from a file instead of
$celebrities = array('britney','gaga','carol');
i couldnt get to implement this one here: what am i doing wrong ?
<?php
$handle = @fopen('array.txt', "r");
if ($handle) {
while (!feof($handle)) {
$celebrities[] = fgets($handle, 4096);
}
fclose($handle);
}
?>