|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
Extract_Body() - Extract the body out of a HTML web page. public function Extract_Body($Page, $Default = null, $IncludeTags = null) {
preg_match('/<body.*\/body>/is', $Page, $Matches);
if (strlen($Matches[0]) == 0) {
if (is_null($Default)) return $Page;
return $Default;
}
if ($IncludeTags === true) return $Matches[0];
preg_match('/<body[^>]*>/is', $Matches[0], $BodyMatch);
$BodyStartTagLength = strlen($BodyMatch[0]);
$BodyEndTagPosition = stripos($Matches[0], '</body>');
return substr($Matches[0], $BodyStartTagLength, $BodyEndTagPosition - $BodyStartTagLength);
}
|
|
|
|
|