$fold[1]) { $point[0] = $fold[1] * 2 - $point[0]; } } if ($fold[0] == 'y') { if ($point[1] > $fold[1]) { $point[1] = $fold[1] * 2 - $point[1]; } } } $coordinates = points_unique($coordinates); echo count($coordinates); //751 die(); } function points_unique($coordinates) { $tmp = []; $newCoordinates = []; foreach ($coordinates as $point) { if (!isset($tmp[implode(',', $point)])) { $newCoordinates[] = $point; $tmp[implode(',', $point)] = 1; } } return $newCoordinates; }