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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:00:28+00:00 2026-05-27T01:00:28+00:00

I want to include an external file, and then get all the content, remove

  • 0

I want to include an external file, and then get all the content, remove the only HTML on the page <br /> and replace with , and fire it into an array.

datafeed.php

john_23<br />
john_5<br />
john_23<br />
john_5<br />

grabber.php

<?php
// grab the url
include("http://site.com/datafeed.php");

//$lines = file('http://site.com/datafeed.php);

// loop through array, show HTML source as HTML source.
foreach ($lines as $line_num => $line) {

    // replace the <br /> with a ,
    $removeBreak = str_replace("<br />",",", $removeBreak);
    $removeBreak = htmlspecialchars($line);
    // echo $removeBreak;
}

// fill our array into string called SaleList
$SaleList = ->array("");

I want to load a php file from the server directory, get the HTML contents of this file and place it into a useable array.

It would look like

$SaleList = -getAndCreateArray from the file above >array("");
$SaleList = ->array("john_23, john_5, john_23");
  • 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-27T01:00:29+00:00Added an answer on May 27, 2026 at 1:00 am

    Here is a working version of grabber.php:

    <?php
    function getSaleList($file) {
        $saleList = array();
        $handle = fopen($file, 'r');
        if (!$handle) {
            throw new RuntimeException('Unable to open ' . $file);
        }
        while (($line = fgets($handle)) !== false) {
            $matches = array();
            if (preg_match('/^(.*?)(\s*\<br\s*\/?\>\s*)?$/i', $line, $matches)) {
                $line = $matches[1];
            }
            array_push($saleList, htmlspecialchars($line));
        }
        if (!feof($handle)) {
            throw new RuntimeException('unexpected fgets() fail on file ' . $file);
        }
        fclose($handle);
        return $saleList;
    }
    
    $saleList = getSaleList('datafeed.php');
    
    print_r($saleList);
    ?>
    

    By using a regular expression to find the <br />, the code is able to deal with many variations such as <br>, <BR>, <BR />, <br/>, etc.

    The output is:

    Array
    (
        [0] => john_23
        [1] => john_5
        [2] => john_23
        [3] => john_5
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to replace the content of the #textoGrande div with an external file.
I want to include a silverlight application (.xap file) inside a HTML page. Using
I have a batch file and I want to include an external file containing
I want to include an external file as a class body, something like this:
We have an external .js file that we want to include in a number
I want to include a batch file rename functionality in my application. A user
I want to include a link in my SiteMaster (using Html.ActionLink) UNLESS the view
I want to include some dynamic part in the filename of the msi file
I want to include the last 2 files in my php file based on
Here's what I need to do -- either : include an external file in

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.