Jump to content

preg_match_all() - Extract content from html


dfz

Recommended Posts

Hi there,

 

I have a static webpage in html. Now I want to extract the content by php so that i will not have to fill in all manually by hand into mysql.

 

The interesting part of my html site is:

<div style="margin-bottom:20px; margin-top:10px;">Here is a question?</div>
      
A) Answer 1 <P>

<strong>B)</strong> Answer 2 <P>

C) Answer 3 <P>

D) Aanswer 4 <P>

</div>

 

As you can see that page contains one question and up to four possible answers. The one that is correct is highlighted as bold.

 

Now how can I use preg_match_all() or even a better function if you know so that i get an array or 5 variables containing the question and the 4 answers?

 

Any ideas? Thanks for your help.

Link to comment
Share on other sites

Learn Regular Expressions, I just happen to know Regular Expressions and I just happen to be looking for work. *hint hint*

 

but, you don't really need regular expressions.. you could use substr nd strpos and parse out the inside of the <divs> but I just noticed.. you only have ONE opening div, and TWO closing divs.. that would be hard either way to parse correctly.

 

Again, I'm looking for work :D *hint*

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.