开发者

How can I get all text after a given phrase?

How can I get everythi开发者_如何学Gong from $string after "<div class='partFive'>"?


try this,

$prefix = "<div class='partFive'>";
$index = strpos($string, $prefix) + strlen($prefix);
$result = substr($string, $index);

obviously you don't have to re-calculate the "strlen" part of it each time if the $prefix value is static.


$myString = strstr($string, "<div class='partFive'>");


Do you need everything after <div class='partFive'> or everything in that DOM element?

I'm assuming you mean you want to grab everything in that DOM element, and the easiest way would be to grab it by using Zend_Dom.

$dom = new Zend_Dom_Query($html);
$results = $dom->query('div.partFive');

foreach ($results as $result) {
    // $result is a DOMElement
}


You could just remove the part you don't want, like so:

$myString = str_replace("<div class='partFive'>","",$string);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜