我需要一些帮助。我有一个秒到分钟的转换器,如果值为0或没有输入元值,我不想显示。我意识到it输出“0分钟”,即使没有输入元值,我也不希望发生这种情况。
这是密码
<strong>
<?php
$duration_in_seconds = get_post_meta( get_the_ID(), \'wpscript_duration\', true );
$minutes = floor($duration_in_seconds / 60);
$seconds = $duration_in_seconds - (60 * $minutes);
echo $minutes;
echo " MIN";
?>
</strong>
最合适的回答,由SO网友:mukto90 整理而成
Use in this way-
<strong>
<?php
$duration_in_seconds = get_post_meta( get_the_ID(), \'wpscript_duration\', true );
if( \'\' != $duration_in_seconds && 0 != $duration_in_seconds ) {
$minutes = floor($duration_in_seconds / 60);
$seconds = $duration_in_seconds - (60 * $minutes);
echo $minutes;
echo " MIN";
}
?>
</strong>