Load an array variable from a file

IMarketing101

New Member
I have the following code which uses an array to write the result to file.I want to create another array to read the celebrities array from another file.\[code\]<?phprequire("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);?>\[/code\]I would also like to load the \[code\]$celebrities\[/code\] array from a file instead of\[code\]$celebrities = array('britney','gaga','carol');\[/code\]I couldnt get this to work. What am I doing wrong?\[code\]<?php$handle = @fopen('array.txt', "r"); if ($handle) { while (!feof($handle)) { $celebrities[] = fgets($handle, 4096); } fclose($handle); } ?>\[/code\]
 
Back
Top