Welcome to WebmasterWorld Guest from 54.221.119.45

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Regular Expression Question

Need help with PHP Regular Expressions

     

wivenhoe

9:03 pm on Apr 20, 2006 (gmt 0)



I've only used regular expressions a couple of times before and never in PHP so need a little help.
I am reading in an external html document (which regular changes) into a variable. I then need to extract a section of it which starts:

<table class="data">

and finishes:

</table>

I'm thinking regular expressions are the way to pull out just this section on the fly. I have looked at prog_match_all but not sure on the pattern to use.

Thanks,
Mark.

Finger

10:01 pm on Apr 20, 2006 (gmt 0)

10+ Year Member



A regular expression would work, but you could also do it with explodes like this:

$text = "(The html code here)";

$temp = explode('<table class="data">',$text,2);
$temp2 = explode('</table>',$temp[1],2);

$extracted_html = $temp2[0];

 

Featured Threads

Hot Threads This Week

Hot Threads This Month