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 8944137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:57:28+00:00 2026-06-15T11:57:28+00:00

When I run the code below, it displays only the web page accessible through

  • 0

When I run the code below, it displays only the web page accessible through the last url listed in “domainslist.txt”. It does not display the earlier web pages.

For example, if “domainslist.txt” contains:

http://example[1].com
http://example[2].com
http://example[3].com

Then the code only displays the web page from example[3].com.

Why does it not display all three?

function url_get_contents($Url) {
        if (!function_exists('curl_init')) {
            die('CURL is not installed!');
        }
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $Url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }

    $urls = file("domainslist.txt", FILE_SKIP_EMPTY_LINES);

    foreach ($urls as $url) {

        echo(url_get_contents($url)); 

    }

NB If I create the array of URLs manually, like this:

$urls = array();
$urls[0] = "http://example[1].com";
$urls[1] = "http://example[2].com";
$urls[2] = "http://example[3].com";

then it works fine, displaying all 3 pages.

EDIT:

When I used var_dump($urls); there is a small difference between the results from the two different methods of forming the arrays. The first two URLs in the array created using file() have two extra characters reported in the string length – but the final URL (the one that displays) is the the right number of characters. However, when the array is created manually, there are no extra characters.

  • 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-06-15T11:57:29+00:00Added an answer on June 15, 2026 at 11:57 am

    add flag FILE_IGNORE_NEW_LINES

    file('domainslist.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    

    manual function file()

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

Sidebar

Related Questions

Why does the code below work fine when I run my web application localhost
Every time I run the code below it is supposed to come up with
When I run the code below NSString *chemin; chemin = [NSString stringWithFormat:@chapitre0%d, [sender tag]];
I am trying to run the code below but it keeps locking up my
I get this error when I run the code below. I have normally used
When I run below code, it's giving a message that: the application stopped unexcepctedlly
When I run the sample code below the width of JTextArea is fixed (100px)
the code below works fine but it takes an absolute age to run. How
When i run the below code I am getting error like ex = {The
When I run the below code, everything goes great until I change the value

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.