Home >Backend Development >PHP Tutorial >三个变量看谁最小。

三个变量看谁最小。

WBOY
WBOYOriginal
2016-06-23 13:31:031148browse

变量a,变量b,变量c

最后,输出变量A最小,变量B最小。或变量C最小

最后,不是取变量里面的最小的值!


回复讨论(解决方案)

$a = 3;$b = 4;$c = 2;$r = array('a' => $a, 'b' => $b, 'c' => $c);echo array_search(min($r), $r); //c

$a = 3;
$b = 4;
$c = 2;
if($a最小){
}
if($b最小){
}
if($c最小){
}
是这个意思,这个如果写呢?

$a = 3;$b = 4;$c = 2;if($a == min($a, $b, $c)) echo '$a 最小';if($b == min($a, $b, $c)) echo '$b 最小';if($c == min($a, $b, $c)) echo '$c 最小';
$c 最小

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn