Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有2个整数。我需要知道哪个具有最小值并获得该值。有什么漂亮的方法(一个功能?)吗?现在我这样做:
$foo = 5; $bar = 7; $min = min($foo, $bar); if($min == $foo) { ... } else { ... }
min()如果您需要使用较低的值,请使用。
min()
$min = min($foo, $bar); print "min: $min";
if如果您只想进行比较,请使用常规
if
if ($foo <= $bar) { // $foo is smaller/equal } else { // $bar is smaller }