如何在此数组中找到max和min值.Below是数组的类型。
Array
(
[0] => Array
(
[uid] => 43543534
)
)
答案 0 :(得分:0)
基于your previous question and its accepted answer,无论如何你都要遍历数组。当你这样做时,你可以计算出最大值:
$maxUid = 0;
foreach ($yourArray as $key => $val) {
$maxUid = max( $maxUid, $val[ 'uid' ] );
// do everything else
}
答案 1 :(得分:0)
$min = 99999999; //to make sure it's not below all the values
$max = 0;
foreach($array as $a){
if($max < max($a)) $max = max($a);
if($min > min($a)) $min = min($a);
}
echo "min: $min, max: $max";