Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $coordinates = [
- [0, 2],
- [2, 4],
- [4, 6]
- ];
- $count = count($coordinates);
- $x = $y = 0;
- foreach( $coordinates as $coordinate ) {
- $x += $coordinate[0];
- $y += $coordinate[1];
- }
- $avgX = ceil( $x / $count );
- $avgY = ceil( $y / $count );
- echo "Average distance is: X: " . $avgX . ", Y: " . $avgY;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement