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.

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*

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.