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

  • Home
  • SEARCH
  • 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 9202345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:14:05+00:00 2026-06-17T23:14:05+00:00

SOLVED: Answer Below HOW TO: – Get all the urls from a file pulled

  • 0

SOLVED: Answer Below

HOW TO:
– Get all the urls from a file pulled using file_get_contents. The file can by dynamic and have multiple URLs
– Replace all urls with custom A NEW URL and add the existing current url on the end as a Variable

Example:

Change the link http://www.ABC.com to http://www.MyWebsite.com/?link=www.ABC.com

FILE NAME: myHTML.html
The HTML email that will be pulled using file_get_contents

<body>
<p>&nbsp;</p>
<p><a href="http://www.CNN.com" target="_blank">Link One</a></p>
<p><a href="http://www.ABC.com" target="_blank">Link Two</a></p>
<p><a href="http://www.foxnews.com/politics/2013/01/28/us-planning-for-new-drone-base-in-northwest-africa-officials-say/" target="_blank">Link Three</a></p>
<p><a href="ObamaMustSee.com" target="_blank">Link Four</a></p>
</body>

Need to OUTPUT to the following Code:

 <body>
<p>&nbsp;</p>
<p><a href="http://www.MyWebsite.com/?link=http://www.CNN.com" target="_blank">Link One</a></p>
<p><a href="http://www.MyWebsite.com/?link=http://www.ABC.com" target="_blank">Link Two</a></p>
<p><a href="http://www.MyWebsite.com/?link=http://www.foxnews.com/politics/2013/01/28/us-planning-for-new-drone-base-in-northwest-africa-officials-say/" target="_blank">Link Three</a></p>
<p><a href="http://www.MyWebsite.com/?link=ObamaMustSee.com" target="_blank">Link Four</a></p>
</body>

Answer that worked for me below!
P.S. +1 If this helped you 🙂

  • 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-17T23:14:06+00:00Added an answer on June 17, 2026 at 11:14 pm

    The PHP Code that works

    PHP code that calls the file and replaces the links

    <?php
    
    $message = file_get_contents("myHTML.html");
    
    
    $content = explode("\n", $message);
    
    $URLs = array();
    
    for($i=0;count($content)>$i;$i++)
    {
         if(preg_match('/<a href=/', $content[$i]))
          {
        list($Gone,$Keep) = explode("href=\"", trim($content[$i]));
        list($Keep,$Gone) = explode("\">", $Keep);
        $message= strtr($message, array( "$Keep" => "http://www.MyWesite.com/?link=$Keep", ));
          }
    }
    
    echo $message;
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Solved in self-answer below. I've looked all over but I can't find anything
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
[SOLVED (see answer below)] I am using SpreadsheetWorker API to make working with Open
SOLVED! See my self-answer below. I'm building two Metro-style apps using Javascript and HTML,
[ANSWER] Thanks everyone! The code to solved the problem below is: SELECT ID FROM
EDIT 2 : I have solved the problem (see answer below) Please note that
UPDATE - No need to answer this now, I have solved below. Hi, I'm
Problem solved: Thanks guys, see my answer below. I have a website running in
Edit: I have solved this by myself. See my answer below I have set
Answer Summary: Solved this problem using Jon Skeet's answer below. Here is the finished

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.