开发者

Get text within div

<div class="plugin-block"> 
<h3><a href="http://wordpress.org/extend/plugins/sailthru-triggermail/">Sailthru</a></h3> 
**Intergrate Sailthru API functionality into your WordPress blog.** 
<ul class="plugin-meta"> 
    <li><span class="info-marker">Version</span> 1.0</li> 
    <li><span class="info-marker">Updated</span> 2010-9-7</li> 
    <li></li> 
    <li> 
开发者_如何学C        <span class="info-marker left">Average Rating</span> 
        <div class="star-holder"> 
            <div class="star star-rating" style="width: 0px"></div> 
            <div class="star star5"><img src="http://wordpress.org/extend/plugins-plugins/bb-ratings/star.gif" alt="5 stars" /></div> 
            <div class="star star4"><img src="http://wordpress.org/extend/plugins-plugins/bb-ratings/star.gif" alt="4 stars" /></div> 
            <div class="star star3"><img src="http://wordpress.org/extend/plugins-plugins/bb-ratings/star.gif" alt="3 stars" /></div> 
            <div class="star star2"><img src="http://wordpress.org/extend/plugins-plugins/bb-ratings/star.gif" alt="2 stars" /></div> 
            <div class="star star1"><img src="http://wordpress.org/extend/plugins-plugins/bb-ratings/star.gif" alt="1 star" /></div> 
        </div> 
    </li> 
</ul> 
<br class="clear" /> 

I need to save the text **Integrate Sailthru API functionality into your Wordpress blog.**

Anyone know how to do this?


It really depends on how much this format might change over time and what you want to rely on as constant. If you want to assume that your html will always start with <div class="plugin-block"> and the text you want will always be on a line after an h3, you can do something like this:

$pattern = '/plugin-block(?:\n|.)*?<\/h3>\s*(.+)/';
preg_match($pattern, $html, $matches);

echo $matches[1]; //**Intergrate Sailthru API functionality into your WordPress blog.**
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜