开发者

Preg_matching content in PHP quick question!

I want to get the content of these:

<div class="scene_box">
WHATEVER IS IN HERE
<div class="clear"></div>

But I cant get the content inbetween

This is my code:

preg_match("/<div class=\"scene_box\">(.*?)<div class=\"clear\"><\/div>

<\/div> /", $res, $match);

if anyone can help it would be much appreciated

theres multiple of the sc开发者_如何学运维ene_box so thats why I am using preg_match


Don't parse HTML with regular expressions. Use something like QueryPath


You already got a better advise with the other answer (which should be a comment however). To extend that with an useful example, this is how extremely easily you could utilize phpQuery or QueryPath for your case:

print qp($html)->find("div.scene_box")->text();

But to also answer your actual regex question, you forgot the /s modifier at the end of your regex. This is why the (.*?) won't match the content in between the markers/tags. The . dot usually ignores line-breaks / CRLF.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜