如何在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);更多推荐
发布评论