(X1, y1) ve x1, x2, y1, y2 ve tamsayı (x2, y2), arasındaki kesimi üzerindeki tüm kafes noktaları (ayrılmaz koordinatları ile puan) oluşturmak için:
function gcd($a,$b) {
    // implement the Euclidean algorithm for finding the greatest common divisor of two integers, always returning a non-negative value
    $a = abs($a);
    $b = abs($b);
    if ($a == 0) {
        return $b;
    } else if ($b == 0) {
        return $a;
    } else {
        return gcd(min($a,$b),max($a,$b) % min($a,$b));
    }
}
function lattice_points($x1, $y1, $x2, $y2) {
    $delta_x = $x2 - $x1;
    $delta_y = $y2 - $y1;
    $steps = gcd($delta_x, $delta_y);
    $points = array();
    for ($i = 0; $i <= $steps; $i++) {
        $x = $x1 + $i * $delta_x / $steps;
        $y = $y1 + $i * $delta_y / $steps;
        $points[] = "({$x},{$y})";
    }
    return $points;
}