Page 1 of 1

Unable to retrieve information between body tags...

Posted: Wed Feb 01, 2006 8:07 am
by raghavan20
I am trying to get the information between body tags but I could not...

Code: Select all

<?php
$input = <<<EOD
<body>
	<b>hi all</b>
</body>
EOD;
echo preg_match_all("/<body>(.*?)<\/body>/mi", $input, $matches)."<br />";
print_r($matches);
?>
</pre>

Posted: Wed Feb 01, 2006 9:16 am
by feyd
you want mode s not mode m. m stops at ends of lines, s does not.

Posted: Wed Feb 01, 2006 9:39 am
by raghavan20
I used 'm' because it allows to read multiple lines as per manual...but I still do not understand how this 's' makes this regex work... :?

Posted: Wed Feb 01, 2006 10:07 am
by feyd
m requires it to be on a single line, s does not.