Regular Expressions:
www.php.net/ereg
www.php.net/preg_match
Or String Matching:
www.php.net/stristr
www.php.net/substr
www.php.net/strpos
Heres a function all setup to do it for you:
http://www.phpbuilder.com/board/showthread.php?s=&threadid=10234010
Heres the actual function:
// $contents is the whole string
// $starttag would be <h3>
// $endtag would be </h3>
// $number should be the number of strings you want returned, it if you just want the first instance of <h3>text</h3> set it to 1, if you wanted to find the second instance too, set it to two, etc.
// returns an array of matches
function Get_String_Between_Strings ($contents, $starttag = ">", $endtag = "<", $number = FALSE) {
$matches = array ();
$starttag_length = strlen ($starttag);
//$contents = strtolower ($contents);
if (strstr ($contents, $starttag)) {
while (strstr ($contents, $endtag)) {
$contents = strstr ($contents, $starttag);
$contents = substr ($contents, $starttag_length);
$tostrip = strstr ($contents, $endtag);
$matches[] = str_replace ($tostrip, "", $contents);
}
}
if ($number) {
$slice = array_slice ($matches, 0, $number);
return ($slice);
} else {
return ($matches);
}
}