Jump to content

Recommended Posts

I'll make it simple.  If I get the process, I can figure out how to incorporate mine better.  Here is the simple version right now:

 

	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;
	}
   		return 0;
}

 

What I would like to do is if there are more than 2 with the same amount of "pts" then check all 3: 

 

	function Compare_standings($ar1, $ar2, $ar3){ 
	if ($ar1['pts']<$ar2['pts']) {
      			return 1;
	} else if ($ar1['pts']>$ar2['pts']) {
      			return -1;
	}
	if ($ar3['pts'] == $ar1['pts']) {
		if (in_array($ar1['id'],$ar2['teamsbeat']) AND in_array($ar3['id'],$ar2['teamsbeat'])) {
			return 1;
		} elseif (in_array($ar2['id'],$ar1['teamsbeat']) AND in_array($ar3['id'],$ar1['teamsbeat'])) {
			return -1;
		}
	} else {
		if (in_array($ar1['id'],$ar2['teamsbeat'])) {
			return 1;
		} elseif (in_array($ar2['id'],$ar1['teamsbeat'])) {
			return -1;
		}
	}
   		return 0;
}

 

Not sure exactly how I should be structuring because not sure how the compare works with more than 2 values, but this should show what I am trying to do.

 

Thanks!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.