21,891
社区成员
发帖
与我相关
我的任务
分享
function dut($f,$dut,$s,$e)
{
$mp = getMax($f[$dut]['binpercent'],$s-1,$e-1);
$resultsArray['Dut'] = 'Bin';
//echo "the max percent is : ".$mp."(bin%".(array_search($mp,$f[$dut]['binpercent'])+1).")<br/>";
//echo $dut."=> bin".(array_search($mp,$f[$dut]['binpercent'])+1)."<br/>";
//echo "=================<br/>";
if(floatval($mp) != 0 )
return array($dut,array_search($mp,$f[$dut]['binpercent'])+1);
else
{
return array($dut,"-");
}
}
<?php
function dut($s, $e, $exString){
$exclude = explode(",", $exString);
$arr = Array();
for($i = $s; $i <= $e; $i++){
if(!in_array($i, $exclude)){
$arr[] = $i;
}
}
$maxValue = max($arr);
return $maxValue;
}
?>function getMax($array,$s,$e='')
{
$f = @array_splice($array,$s,$e);
$i = 0;
foreach($f as $v){
if(rtrim($v,'%')+0 > rtrim($i,'%')+0){
$i = $v;
}
}
return $i;
}原格式是:
1|110|0|0|0|0|0|0|0|110|100%|0.00%|0.00%|0.00%|0.00%|0.00%|0.00%|0.00%,
2|110|0|0|0|0|0|0|0|110|100%|0.00%|0.00%|0.00%|0.00%|0.00%|0.00%|0.00%,
....
对应名称
dut bin1 bin2 bin3 ... bin8 bin_all bin1% bin2% ... bin8%
其中bin_all是bin1+bin2+...+bin8的和
再贴一个getMax的结果:
the max percent is : 12.14%(bin%5)
8=> bin5
=================
the max percent is : 99.43%(bin%6)
21=> bin6
=================
the max percent is : 31.03%(bin%5)
31=> bin5
=================
the max percent is : 11.49%(bin%7)
37=> bin7
=================
the max percent is : 40.23%(bin%6)
41=> bin6
=================
the max percent is : 14.37%(bin%6)
51=> bin6
=================
the max percent is : 3.53%(bin%5)
81=> bin5
=================
the max percent is : 11.18%(bin%7)
93=> bin7
=================
the max percent is : 80.59%(bin%7)
94=> bin7
=================
the max percent is : 8.24%(bin%5)
96=> bin5
=================
the max percent is : 10%(bin%7)
102=> bin7
=================