仅当存在';t页面某个区域的数字相同


Execute code only if there isn't the same number in an area of the page?

基本上,我想要这个:

The highest voted
answer 3 vote
The others
answer 1 vote
answer 2 vote
answer 1 vote

但我想避免这种情况:

The highest voted
answer 3 vote
The others
answer 3 vote
answer 3 vote
answer 1 vote

这是没有道理的,因为还有其他答案在下面投了3票。

所以我想创建这样一个if-else语句:

(run this only if there isn't posts with the same amount of votes)
The highest voted
answer 3 vote
(end if)
The others
answer 3 vote
answer 3 vote
answer 1 vote

因此,在这种情况下,代码(评分最高的答案)不应该运行。

我不确定我应该使用php还是jQuery。

The_votes();函数输出的内容如下:+2 votes,所以我不能直接使用它,因为它有文本。

我可以根据div或div类进行比较。

有什么关于如何编码的建议吗?

编辑:

每个答案的PHP和HTML内容示例:

    <h2><?php the_title(); ?></h2>
        <?php the_content(); ?>
        <?php bbp_reply_admin_links(); ?>
        <h4><?php bbp_topic_reply_count(); ?></h4>
        <div class="topic-like-count">
    <?php if(function_exists('the_votes')) { the_votes(); } ?>

我想我只需要从笔记中得到数字,然后做点什么。

为什么不能使用voting();

即使返回类似+xx votes;的文本,您也可以使用检索数字

$voting = voting();
$votes = substr($voting,1,strpos($voting,' ')-1);