Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1107127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:53:40+00:00 2026-05-17T01:53:40+00:00

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);

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:53:41+00:00Added an answer on May 17, 2026 at 1:53 am

    Assuming you have a single celeb per line:

    $celebrity = trim(fgets($read_file));
    

    As fgets will return a string including the newline character.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 538k
  • Answers 538k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Hey I resolved this myself, turns out that I cannot… May 17, 2026 at 1:54 am
  • Editorial Team
    Editorial Team added an answer I am sure there are better ways to go about… May 17, 2026 at 1:54 am
  • Editorial Team
    Editorial Team added an answer That is weird advice. The NVL function works like this:… May 17, 2026 at 1:54 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have this code: require 'rubygems' require 'activeresource' ActiveResource::Base.logger = Logger.new(#{File.dirname(__FILE__)}/exercises.log) class Exercise <
Hallo I have this script: <? require(lib2/config.inc.php); require(lib2/tpl.class.php); require(lib2/db.class.php); require(lib2/um.class.php); $tpl = new template(templates,
I have this code in the __constructor $this->Reliability = new Reliability(name,url); Problem: I got
I have the following code require 'test_helper' class ApplicationControllerTest < ActionController::TestCase test should display
Say I have a file Foo.php: <?php interface ICommand { function doSomething(); } class
I have this in my application_helper.rb : def bbcode(text) # Code snippets text.gsub!(/\[code=?[']?(.*?)[']?\](.*?)\[\/code\]/mis) {
I have this weird code on site. It gets all records (order by pozycja),
Consider the following PHP code: <?php require_once(myDBclass.php); class a { private $tablename; private $column;
Python noob here, Currently I'm working with SQLAlchemy, and I have this: from __init__
I have posted this yesterday, I didn't get the the answers that could solve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.