tie breaker code problem?
Posted: Mon Dec 13, 2004 3:58 pm
$sum is an array of 9 sums, i am trying to code things so that highest sum becomes $main, and if there is tie between two or more sums, then $main is selected randomly from the tying sums. the current code yields the highest scoring sum, but does not randomly break ties very well (if there is a tie). what do i need to add to break ties better? (currently the sum sooner or latter in the array gets selected when there is a tie, which means middle tieing numbers are never selected)
Code: Select all
<?php
$sum=split(":",$row[temp]);
$sumsort=$sum;
arsort($sumsort);
reset($sumsort);
foreach($sumsort as $k=>$v){
$main=$k+1;break;
?>