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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:53:06+00:00 2026-05-31T18:53:06+00:00

I am requesting the source code of a website like this: <? $txt =

  • 0

I am requesting the source code of a website like this:

<? $txt = file_get_contents('http://stats.pingdom.com/qmwwuwoz2b71/522741');
echo $txt; ?>

Bu I would like to replace the relative links with absolute ones! Basically,

<img src="/images/legend_15s.png"/> and <img src='/images/legend_15s.png'/>

should be replaced by

<img src="http://domain.com/images/legend_15s.png"/> 

and

<img src='http://domain.com/images/legend_15s.png'/>

respectively. How can I do this?

  • 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-31T18:53:08+00:00Added an answer on May 31, 2026 at 6:53 pm

    This code replaces only the links and images:

    <? $txt = file_get_contents('http://stats.pingdom.com/qmwwuwoz2b71/522741');
    $txt = str_replace(array('href="', 'src="'), array('href="http://stats.pingdom.com/', 'src="http://stats.pingdom.com/'), $txt);
    echo $txt; ?>
    

    I have tested and its working 🙂

    UPDATED

    Here is done with regular expression and working better:

    <? $txt = file_get_contents('http://stats.pingdom.com/qmwwuwoz2b71/522741');
    $domain = "http://stats.pingdom.com";
    $txt = preg_replace("/(href|src)\=\"([^(http)])(\/)?/", "$1=\"$domain$2", $txt);
    echo $txt; ?>
    

    Done 😀

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

Sidebar

Related Questions

When requesting http://someserver.com/user/btyndall I'd like to return HTML When requesting http://someserver.com/user/btyndall?format=xml I'd like to
I have written small C++ console application and this is source code : #include<stdio.h>
Client is requesting a single track to be heard across the website. Generally I
Unsigned application requesting unrestricted access to system Unsigned resource: http://*/kis/adfjars/sqlj/lib/runtime12.jar Exception: <jar href=http://*/kis/adfjars/jlib/oracle-el.jar download=eager
I have a client requesting an animated/panned image be added to their website. Basically,
Consider the following code: print cwd . \n; $str= ../source; # note the lower
I'm having this issue with cucumber when. Here is everything. My Gemfile source 'https://rubygems.org'
I am using jQuery.ajax ( http://docs.jquery.com/Ajax/jQuery.ajax ) to inject the contents of a different
I have a website with Facebook integration. The homepage has a few Like buttons,
I'm requesting data from an online source which I then decode into json StdClass

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.