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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:11:03+00:00 2026-05-14T19:11:03+00:00

Ive gotten some great help here and I am so close to solving my

  • 0

Ive gotten some great help here and I am so close to solving my problem that I can taste it. But I seem to be stuck.

I need to scrape a simple form from a local webserver and only return the lines that match a users local email (i.e. onemyndseye@localhost). simplehtmldom makes easy work of extracting the correct form element:

foreach($html->find('form[action*="delete"]') as $form) echo $form;

Returns:

<form action="/delete" method="post">
    <input type="checkbox" id="D1" name="D1" /><a href="http://www.linux.com/rss/feeds.php">
        http://www.linux.com/rss/feeds.php
    </a> [email: 
        onemyndseye@localhost (Default)
    ]<br />         
    <input type="checkbox" id="D2" name="D2" /><a href="http://www.ubuntu.com/rss.xml">
        http://www.ubuntu.com/rss.xml
    </a> [email: 
        onemyndseye@localhost (Default)
    ]<br />         
<input type="submit" name="delete_submit" value="Delete Selected" /></form>

However I am having trouble making the next step. Which is returning lines that contain ‘onemyndseye@localhost’ and removing it so that only the following is returned:

<input type="checkbox" id="D1" name="D1" /><a href="http://www.linux.com/rss/feeds.php">http://www.linux.com/rss/feeds.php</a> <br />
<input type="checkbox" id="D2" name="D2" /><a href="http://www.ubuntu.com/rss.xml">http://www.ubuntu.com/rss.xml</a> <br />

Thanks to the wonderful users of this site Ive gotten this far and can even return just the links but I am having trouble getting the rest… Its important that the complete <input> tags are returned EXACTLY as shown above as the id and name values will need to be passed back to the original form in post data later on.

Thanks in advance!

***** EDIT ******

Issue close to solved now thanks to Yacoby. The last small hurdle is that some trash is left behind from the str_ireplace. Perhaps it would be easier to remove all text between </a> and <br /> …?

After Yacoby’s additions the output is as follows:

<form action="/delete" method="post">
    <input type="checkbox" id="D1" name="D1" /><a href="http://www.linux.com/rss/feeds.php">
        http://www.linux.com/rss/feeds.php
    </a> [email: 
         (Default)
    ]<br />         
    <input type="checkbox" id="D2" name="D2" /><a href="http://www.ubuntu.com/rss.xml">
        http://www.ubuntu.com/rss.xml
    </a> [email: 
         (Default)
    ]<br />         
    <input type="checkbox" id="D3" name="D3" /><a href="http://mythbuntu.org/rss.xml">
        http://mythbuntu.org/rss.xml
    </a> [email: 

    ]<br />         
<input type="submit" name="delete_submit" value="Delete Selected" /></form>

Notice [email: (Default)] and [email: ] have been left behind. Also would need to remove the form action and submit lines at last but that part I think i can gather from the previous suggestion.

***** SOLVED ****

issue solved with:

$html = file_get_html('http://localhost:9000/');
foreach($html->find('form[action*="delete"]') as $form)
  if ( stripos($form->innertext, 'onemyndseye@localhost') !== false ){
      $form = preg_replace('!</a>.*?<br />!s', '</a><br />', $form);
      echo $form;
}

Thanks for the help!

  • 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-14T19:11:05+00:00Added an answer on May 14, 2026 at 7:11 pm

    Maybe something like

    if ( stripos($form->innertext, 'onemyndseye@localhost') !== false ){
        $form->innertext = str_ireplace('onemyndseye@localhost', '', $form->innertext);
        echo $form;
    }
    

    This won’t work with html like

    <b>onemyndseye</b>@localhost
    

    As it is easy to find if the text with tags removed matches a string using plaintext but it is far harder to replace.

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

Sidebar

Related Questions

My original question can be found here , for which I've gotten some great
I've gotten some help here for this piece of code, but on my end,
I'm having a great time learning Python, but I've just gotten a bit stuck
I'm building some sort of censoring app. I've gotten so far that i can
I've gotten some good help on here with some tricky stuff like this, so
I'm taking a crack at my PHP again but I've gotten stuck on some
I've been reading this site for a few months, and gotten some great answers
I've had some exposure to Visual Studio, but not a great deal, as well
Lately, I've gotten some weird linker errors. I've been taught that there's two ways
I noticed that VS2010 has some great new ways to build Sharepoint content. List

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.