In some code I;m writing, I have the following bit:
preg_match_all('value="^[0-9]+-[0-9]+$',$wTxt,$LocationMatches)
$wTxt is a bit of HTML code that should contain 3, 5, or 8 matches to the above expresion, creating $LocationMatches as an array with 3,5, or 8 entries. In this case, the entries are x-y co-ordinates. (If the code I'm using above won't do that, let me know, of course!)
The sticking point for me is, I want to find the average value of x and the average value of y. I'm betting a proper use of some math and the foreach iteration on $LocationMatches would do the trick, but can't figure out the method to using the keys combined with the iteration and such.
Here's an example of a rather likely array I'd expect to see as a result of the above code and need worked on and the results I need to get:
example of likely input: $LocationMatches = array('22-10',23-10','24-10','22-11','24-11','22-13',23-13','24-13')
desired output from example $LocationMatches array: $xPos=23 $yPos=11
note- decimal result values for $xPos and $yPos are OK and are expected in certain cases.