PHP - 用两个更短的语句制作 if 语句

钥匙大师

我有以下 If 语句,我想让它更短(例如,单行),而不是在一行中写下我的 if 语句。

    if ($start + $count > $total) {
        $count = $total;
    }

基本上我想实现$count+$total永远不会更高$total,如果是这种情况,我想设置$count等于$total.

贾斯汀

你可以使用min()

$count = min($total, $start + $count);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章