Forum Moderators: coopster

Message Too Old, No Replies

Parsing text inside of <blockquote>?

         

JohnKelly

9:50 pm on Nov 15, 2007 (gmt 0)

10+ Year Member



I'm trying to parse out text within the <blockquote></blockquote> tags. The text may span multiple lines (therefore contain line breaks), and may have other HTML within the <blockquote> tags. All I've got so far is:

if (preg_match("/<blockquote>(.)*<\/blockquote>/i", $contents, $matches)) {
$stuff = $matches[0];
}
echo $stuff;

... which doesn't seem to work, at least not over multiple lines.

PHP_Chimp

9:52 pm on Nov 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[uk.php.net...]

look at the m and s modifiers they may well help with the multi lines.

JohnKelly

9:56 pm on Nov 15, 2007 (gmt 0)

10+ Year Member



Changed code to include /msi at end of regex and it did the trick, thanks!

if (preg_match("/<blockquote>(.)*<\/blockquote>/msi", $contents, $matches)) {
$stuff = $matches[0];
}
echo $stuff;