Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Regular Expression Question

Need help with PHP Regular Expressions



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

Inactive Member
Account Expired


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:


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.


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

New User

10+ Year Member

joined:Sept 19, 2003
votes: 0

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];