开发者

How to get a number inside a div in order to use it in a php if-statement?

Right now, I do something 开发者_Go百科like this:

<h4><?php bbp_topic_reply_count(); ?></h4>
 <?php if ( bbp_get_topic_reply_count() == 1 ) : ?>
  <span><?php _e( 'reply' ); ?></span>
 <?php else : ?>
  <span><?php _e( 'replies' ); ?></span>
 <?php endif; ?>

So if there is only one reply it says: reply and if there are more it says replies.

Now for the voting part its a little bit more complicated. The function looks like this: <?php wp_gdsr_render_article_thumbs(); ?> and it renders something like this:

<div class="thumblock ">
1
<div class="ratingtext ">
<div class="raterclear"></div>
</div>

In this example, I need to get that "1" to use it as I did in the if-statement I showed above.

EDIT:

I tried this:

<div class="topic-like-count">
 <h4><?php wp_gdsr_render_article_thumbs(); ?></h4>
</div>
 <?php preg_match( '!<div class="thumblock ">(.*)</div>!si' ,        wp_gdsr_render_article_thumbs() , $n );
echo strip_tags( $n[1] ); ?>
 <span><?php _e( 'likes' ); ?></span>
</div>

But the whole .thumblock div is output again:

<div class="topic-like-count">
<h4>
<div class="thumblock ">

 ...

</h4>

<div class="thumblock ">

...

<span>likes</span>
</div>

Any suggestions?


if i think correct, below code should help you :

Last Edit : ( thanks to Kaolis )

preg_match( '!<div class="thumblock ">(.*)</div>!si' , wp_gdsr_render_article_thumbs(0, false, "", 0, "", false) , $n );
echo strip_tags( $n[1] );
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜