1, 'down' => 1], ['Right' => 3, 'down' => 1], ['Right' => 5, 'down' => 1], ['Right' => 7, 'down' => 1], ['Right' => 1, 'down' => 2], ]; $result = 1; foreach ($tests as $i => $test) { $right = 0; $down = 0; $count_trees = 0; while ($right < $length && $down < $height) { if ($map[$down][$right] === '#') { $count_trees++; } $right += $test['Right']; $down += $test['down']; } // echo sprintf('Trouvé %u arbres sur le parcours %u', $count_trees, $i); $result *= $count_trees; } echo $result;