我有这样一句话:
<h5>There are <?php echo $total_results_count; ?> results waiting for you!</h5>
我怎么能修改这个来说:
There is 1 result waiting for you!
如果只有1个结果。
答案 0 :(得分:1)
将结果输入变量。然后,
if($count == 1){
str_replace("are results","is 1 result ","There are results waiting for you!");
}
答案 1 :(得分:-1)
一样简单:<h5>There <?php if($total_results_count>1) echo "are"; else echo "is" $total_results_count. " result"; if($total_results_count>1) echo "s";?> waiting for you!</h5>
答案 2 :(得分:-1)
<h5><?php
if ($total_results_count > 1) {
echo 'There are ' . $total_results_count . ' results';
}
else {
echo 'There is ' . $total_results_count . ' result';
} ?> waiting for you!</h5>
答案 3 :(得分:-1)
<?php
if( $total_results_count > 1 ) {
echo '<h5>There are '.$total_results_count.' results waiting for you!</h5>';
} else {
echo '<h5>There is 1 result waiting for you!</h5>';
}