如何在Wordpress中显示最高值(How to display the highest value in Wordpress)

编程入门 行业动态 更新时间:2024-10-24 06:29:05
如何在Wordpress中显示最高值(How to display the highest value in Wordpress)

我在WordPress中发布了这两个值,每个值都返回一个区域:

<?php listingpress_property_area(); ?> <?php listingpress_property_areautil(); ?>

我只需要显示最高的; 可能吗?

上述函数返回值如200和600或400和300,我需要一些采用这两个值并返回最高值的东西。

I have these two values in a post in WordPress, each of them returns an area:

<?php listingpress_property_area(); ?> <?php listingpress_property_areautil(); ?>

and I only need to show the highest; is it possible?

The above functions return values such as 200 and 600 or 400 and 300 and I need something that takes the two values and returns only the highest.

最满意答案

首先,输出到变量。 这是通过ob_start()和ob_get_clean()来解决的,它将所有输出放到缓冲区而不是屏幕并将缓冲区返回给变量。 然后比较两个变量并回显最高值:

ob_start(); listingpress_property_area(); $a = ob_get_clean(); ob_start(); listingpress_property_areautil(); $b = ob_get_clean(); echo max($a, $b);

First, get output to variables. This is solved by ob_start() and ob_get_clean(), which put all output to buffer instead of the screen and return buffer to a variable. Then compare two variables and echo the highest:

ob_start(); listingpress_property_area(); $a = ob_get_clean(); ob_start(); listingpress_property_areautil(); $b = ob_get_clean(); echo max($a, $b);

更多推荐

本文发布于:2023-08-04 10:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415319.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最高值   如何在   highest   Wordpress   display

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!