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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:35:34+00:00 2026-05-16T05:35:34+00:00

fff.html is an email with email addresses in it some have href mailto links

  • 0

fff.html is an email with email addresses in it some have href mailto links and some don’t, i want to scrape them and output them into the following format

Lorem@ipsum.com,dolor@sit.com,amet@consectetur.com

I have a simple scraper to get the ones that are href linked but something is wierd

  <?php
    $url = "fff.html";
    $raw = file_get_contents($url);

    $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
    $content = str_replace($newlines, "", html_entity_decode($raw));

    $start = strpos($content,'<a href="mailto:');
    $end = strpos($content,'"',$start) + 8;
    $mail = substr($content,$start,$end-$start);

    print "$mail<br />";
    ?>

I should get extra points for the original use of lorem ipsum

  • 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-16T05:35:35+00:00Added an answer on May 16, 2026 at 5:35 am

    The problem is what if you have more than one email address in the HTML page. substr will only return the first instance. Here is a script that will parse all email addresses. You may need to tweak it some for your use. It will output the results in the CSV form you requested.

    <?php
    $url = "fff.html";
    $raw = file_get_contents($url);
    
    $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
    $content = str_replace($newlines, "", html_entity_decode($raw));
    
    $start = strpos($content, '<body>');
    $end = strpos($content, '</body>');
    $data = substr($content, $start, $end-$start);
    
    $pattern = '#a[^>]+href="mailto:([^"]+)"[^>]*?>#is';
    preg_match_all($pattern, $data, $matches);
    
    foreach ($matches[1] as $key => $email) {
        $emails[] = $email;
    }
    echo implode(', ', $emails );
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of html links, that I have onmouseover and onmouseout set
I've got a simple html-list which contains elements like this: <li> <a href=http://somecool url.com/>some
My HTML : <tr><td>Text</td><td><input type=text value=></td></tr> My CSS : input:focus tr{ background-color:#fff;} I want
I have the following HTML: <div style=float:left; background-color:#0CC;>Floating Left</div> <div style=background-color:#03C; color:#FFF;>Not floating</div> Which
I have the following code: <HTML> <head> <style>div{border:dashed 1px silver}</style> </head> <BODY style=background: #fff;>
I have the following HTML to center images and links within a layer: edit:
I have the following HTML: <a href=>Bioshock 2<span> - Xbox 360 review</span></a> I'd like
I have this set of html and css. What I want is to have
i want to insert image on page using javascript function //JS $('#fff').html('<img src=../images/pic.jpeg>'); when
The body-Tag of a HTML-File does have a background-image applied: body {… background: #fff

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.