Advent of code 2020/3
Ajax Direct

Answer

Part 1 :
Part 2 :
function get_trees_hit($slope)
{
    global $input;
    $trees = grid($input, 1);
    $me    = xy([0, 0]);
    $hit   = 0;
    [$width, $height] = [$trees->width(), $trees->height()];

    while (true) {
        $me->directions($slope);

        // OOB x -> extend trees
        if ($me[0] >= $width) {
            $trees = $trees->repeatX();
            $width *= 2;
        }

        // OOB y -> stop there
        if ($me[1] >= $height) {
            return $hit;
        }

        if ($trees->get($me) == "#") {
            $hit++;
        }
    }
}

// ==================================================
// > SOLUTIONS
// ==================================================
$solution_1 = get_trees_hit([["right", 3], ["down", 1]]);

$solution_2 = set([
    [["right", 1] , ["down", 1]],
    [["right", 3] , ["down", 1]],
    [["right", 5] , ["down", 1]],
    [["right", 7] , ["down", 1]],
    [["right", 1] , ["down", 2]]
])->map("get_trees_hit")->multiply();