时间:2021-07-01 10:21:17 帮助过:4人阅读
select max(concat(a,'-', b)) as a,sum(b) as b from test
$a = array(10, 30, 50);
$b = array(2, 5, 4);
$max = max($a);
$sum = 0;
foreach($a as $i=>$v)
if($v < $max) $sum += $b[$i];
echo $max + $sum;
$arr = array(
array(10, 2),
array(30, 5),
array(50, 4)
);
$index = 0;
$max = 0;
for($i=0,$len=count($arr); $i<$len; $i++){
if($arr[$i][0]>$max){
$max = $arr[$i][0];
$index = $i;
}
}
$total = $max;
for($i=0,$len=count($arr); $i<$len; $i++){
if($i==$index){
continue;
}
$total += $arr[$i][1];
}
echo $total; // 57