gpt4 book ai didi

php - 仅当页面某个区域中没有相同的数字时才执行代码?

转载 作者:行者123 更新时间:2023-12-01 05:05:34 27 4
gpt4 key购买 nike

基本上,我想要这个:

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(); } ?>

我想我必须只从 the_votes 中获取数字并做一些事情。

最佳答案

为什么不能使用voting();

即使返回像 +xx votes; 这样的文本,您也可以通过以下方式检索号码:

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

关于php - 仅当页面某个区域中没有相同的数字时才执行代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6280584/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com