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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:42:21+00:00 2026-06-12T21:42:21+00:00

I am not sure if this is even possible but I am trying to

  • 0

I am not sure if this is even possible but I am trying to extract all the anchor tag links in a few HTML files on my website. I have currently written a php script that scans a few directories and sub directories that builds an array of HTML file links. Here is that code:

$di = new RecursiveDirectoryIterator('Migration'); 
$migrate = array();
foreach (new RecursiveIteratorIterator($di) as $filename => $file) { 
if (eregi("\.html",$file) || eregi("\.htm",$file) ) {
$migrate[] .= $filename; 
}
}

This method successfully produces the HTML File links that I need. Ex:

Migration/administration/billing/Billing.htm
Migration/administration/billing/_notes/Billing.htm.mno
Migration/administration/new business/_notes/New Business.htm.mno
Migration/administration/new business/New Business.htm
Migration/account/nycds/_notes/NYCDS Index.htm.mno
Migration/account/nycds/NYCDS Index.htm

There’s more links but this gives you an idea. The next part is where I am stuck. I was thinking that I would need a for loop to loop through each array element, open the file, extract the links, then store those links somewhere. I am just not sure how I would go about this process. I tried to google this question but I never seemed to get results that matched what I was looking to do. Here is the simplified for loop that I have.

var obj = <?php echo json_encode($migrate); ?>;
for(var i=0;i< obj.length;i++){ 
// alert(obj[i]);
} 

The above code is in javascript. From what I am reading, It seems that I shouldn’t be using javascript but should maybe continue using PHP. I am confused on what my next steps should be. If someone can point me in the right direction I would really appreciate it. Thank you so much for your time.

  • 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-12T21:42:24+00:00Added an answer on June 12, 2026 at 9:42 pm

    Use DOMDocument::getElementsByTagName to retrieve all <a> tags

    http://www.php.net/manual/en/domdocument.getelementsbytagname.php

    Example,

    $doc = new DOMDocument();
    $doc->loadHTMLFile("filename.html");
    $anchors = $doc->getElementsByTagName('a'); //retrieve all anchor tags
    foreach ($anchors as $a) { //loop anchors
        echo $a->nodeValue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure if this is even possible but I am trying to save text
I'm not sure if this is even possible, but I am trying to do
I'm not sure this is even possible but I know if it is, the
I'm not sure if this is even possible, but is there a way to
Ok, not sure if this is even possible, but I want to change the
Hello! I'm not even sure if this is possible, but hopefully it is in
First of all I'm not sure this is even possible, however I need to
I'm not even sure what this is called? But I'm trying to learn what
I'm not sure if this is even possible, but I figured I'd ask before
Im not sure how I can achieve this or if its even possible but

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.