Hmm.. I've tried the following but the the car with the largest 'styling' attribute doesn't display. It only shows when it wins overall as well as on the 'styling' attribute.
<?php
function getWinner($chosen, $attr = null) {
$index = $topStats = 0;
foreach ($chosen as $key => $data) {
if ($attr != null && $data[$attr] > $topStats) {
$topStats = $data[$attr];
$index = $key;
continue;
}
if (array_sum($data) > $topStats) {
$index = $key;
$topStats = array_sum($data);
}
}
return $chosen[$index];
}
echo '<pre>';
// randomSet contains my final array of cars to compare
$winner = getWinner($randomSet);
$winner_on_attribute = getWinner($randomSet, 'styling');
print "<h1>Overall Winner</h1>";
print_r($winner);
print "<h1>Styling attribute Winner</h1>";
print_r($winner_on_attribute);
echo '</pre>';
?>