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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:19:55+00:00 2026-06-08T06:19:55+00:00

bit stuck on this, what I’m looking to do is loop a list of

  • 0

bit stuck on this,
what I’m looking to do is loop a list of URL’S which contain links back to my site,
I’m looking to capture the HTML code used to produce the link and alternatively store the anchor text which is used as the link,

[code removed by marty see below]

so the code used for martylinks uses a function im still trying to buid, this is were im having a little trouble, but for you guys im sure its really simple..

this is my find_marty_links function

function find_marty_links($file, $keyword){
    //1: Find link to my site <a href="http://www.***martin***-gardner.co.uk" target="_blank" title="Web Developer">Web Developer</a>
    //2: copy the FULL HTML LINK to array
    //3: copy the REL value? NOFOLLOW : FOLLOW to array
    //4  copy TITLE (if any) to array
    //5  copy Anchor Text to array

    $htmlDoc = new DomDocument();
    $htmlDoc->loadhtml($file);

    $output_array = array();
    foreach($htmlDoc->getElementsByTagName('a') as $link) {

            // STEP 1
        // SEARCH ENTIRE PAGE FOR KEYWORD?
            // FIND A LINK WITH MY KEYWORD?
            preg_match_all('???', $link, $output); //???//

            if(strpos($output) == $keyword){


               // STEP 2
               // COPY THE FULL HTML FOR THAT LINK?
               $full_html_link = preg_match(??);
               $output_array['link_html'] = $full_html_link;

               // STEP 3
               // COPY THE REL VALUE TO ARRAY
               $link_rel = $link->getAttribute('rel');
               $output_array['link_rel'] = $link_rel;

               // STEP 4
               // COPY TITLE TO ARRAY
               $link_title = $link->getAttribute('title');
               $output_array['link_title'] = $link_title;

               // STEP 5
               // COPY ANCHOR TEXT TO ARRAY
               $anchor_exp = expode('>'); //???
               $anchor_txt = $anchor_exp[2];//??
               $output_array['link_anchor'] = $anchor_txt;

            }

    }
}

!!UPDATE!!
need to produce an Array like below

$results = array('link_html' => '<a title="test" href="http://site.com" rel="nofollow">anchor text</a>',
                 'link_rel' => 'nofollow',
                 'link_title' => 'test',
                 'link_anchor' => 'anchor text'
                 )

thanks for any help lads..

M

  • 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-08T06:19:58+00:00Added an answer on June 8, 2026 at 6:19 am

    Ok here is the updated code:

    function find_marty_links($file, $keyword){
        $htmlDoc = new DomDocument();
        $htmlDoc->loadhtml($file);
        $links = array();
    
        foreach($htmlDoc->getElementsByTagName('a') as $link) {
            $url = $link->getAttribute('href');
            $title = $link->getAttribute('title');
            $text = $link->nodeValue;
            $rel = $link->getAttribute('rel');
    
            if(strpos($url,$keyword) !== false || strpos($title,$keyword) !== false || strpos($text,$keyword) !== false)
            {
                $links[] = array('url' => $url, 'text' => $text, 'title' => $title, 'rel' => $rel);
            }
        }
    
        return $links;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone can help me, I am a bit stuck. I have this query which
I've come a bit stuck this afternoon with a bug in my web application
I'm a bit stuck on this - I am using a Wordpress shortcode with
hi i am a bit stuck with this. what i am going to work
I am bit stuck with this one.. what i want is update app_name (first
I'm a wee bit stuck on this, and was hoping you might have some
I seem to be a bit stuck on this, but my experience in Linq
I'm a bit stuck with which charting library I will use in my project.
Okay i'm a little bit stuck on how to solve this problem. When a
I am a bit stuck on how I should model this out. Here is

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.