fanfavorite Posted March 30, 2009 Share Posted March 30, 2009 I have a function that is used to rank teams. It is as follows: function Compare_standings($ar1, $ar2){ if ($ar1['pts']<$ar2['pts']) { return 1; } else if ($ar1['pts']>$ar2['pts']) { return -1; } if (in_array($ar1['id'],$ar2['teamsbeat'])) { return 1; } elseif (in_array($ar2['id'],$ar1['teamsbeat'])) { return -1; } if ($ar1['w']<$ar2['w']) { return 1; } else if ($ar1['w']>$ar2['w']) { return -1; } if ($ar1['ga'] == 0) { $arg1 = 1; } else { $arg1 = $ar1['ga']; } if ($ar2['ga'] == 0) { $arg2 = 1; } else { $arg2 = $ar2['ga']; } if (($ar1['gf'] + $ar1['ga']) / $arg1 < ($ar2['gf'] + $ar2['ga']) / $arg2) { return 1; } elseif (($ar1['gf'] + $ar1['ga']) / $arg1 > ($ar2['gf'] + $ar2['ga']) / $arg2) { return -1; } return 0; } This all works perfect except at "if (in_array($ar1['id'],$ar2['teamsbeat'])) {", I need to check if any other teams in the array have the same amount of points (pts) and if they do, then if one of the tied teams has beaten all other tied teams, rank that team highest. I hope this is not too confusing. I basically need to know if I can compare a 3rd value in this function somehow. Thanks. Link to comment https://forums.phpfreaks.com/topic/151796-uasort-compare-3-or-more-values/ Share on other sites More sharing options...
fanfavorite Posted March 31, 2009 Author Share Posted March 31, 2009 Can anyone help? I am stuck here. Please take a look. Thanks. Link to comment https://forums.phpfreaks.com/topic/151796-uasort-compare-3-or-more-values/#findComment-797695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.