diff --git a/methods/schulzeResults.php b/methods/schulzeResults.php index baed706..69fb437 100644 --- a/methods/schulzeResults.php +++ b/methods/schulzeResults.php @@ -33,19 +33,17 @@ class schulze $r = array(); foreach($votes as $vote) { - $r[] = implode($vote); + $r[] = implode("/", $vote); } return $r; } - function votify($votes) + function votify(&$votes) { - $r = array(); foreach($votes as $vote) { - $r[] = explode($vote); + $vote["vote"] = explode("/", $vote["vote"]); } - return $r; } function test($v) @@ -58,21 +56,17 @@ class schulze print_r($v); for($i = 0;$i < count($v) - 1;$i++) { + $s = $v[$i]; if ($i == 0) { - $w[$j]["vote"] = $v[$i]; - $w[$j]["n"] = 1; - $j += 1; + $w[$s] = 1; } - if ($v[$i] === $v[$i+1]) + if ($s == $v[$i+1]) { - $x = array_search($v[$i], $w); - $w[$x]["n"] += 1; + $w[$s] += 1; }else { - $w[$j]["vote"] = $v[$i+1]; - $w[$j]["n"] = 1; - $j += 1; + $w[$s] = 1; } } $w = votify($w);