Erik Smith
New member
Objective: I am trying to extract everything within the <body> tag. I need to be able to extract <body> or <body bgcolor="black"> or <BODY BGCOLOR="black">.
This is what I have so far in php:
<?php
$string = "<html>" . "<BoDy bgColor=\"\">" . "</body>" . "</html>";
$regexp = '/<body\s?(.*)>/i';
if(preg_match_all($regexp,$string, $matches)){
$counter = 0;
foreach($matches as $match)
{
print_r($match);
echo "<br />";
print_r($string);
}
print($match[0]);
}// end if
?>
Outputs:
Array ( [0] => )
Array ( [0] => bgColor="">
bgColor="">
Problem: It doesn't extract the <body> tag. Any help here would be appreciated
This is what I have so far in php:
<?php
$string = "<html>" . "<BoDy bgColor=\"\">" . "</body>" . "</html>";
$regexp = '/<body\s?(.*)>/i';
if(preg_match_all($regexp,$string, $matches)){
$counter = 0;
foreach($matches as $match)
{
print_r($match);
echo "<br />";
print_r($string);
}
print($match[0]);
}// end if
?>
Outputs:
Array ( [0] => )
Array ( [0] => bgColor="">
bgColor="">
Problem: It doesn't extract the <body> tag. Any help here would be appreciated