0, 'y' => 0]; $trees = 0; while ($current_coords['y'] < (count($coords) - 1)) { $current_coords['x'] += $incr_x; $current_coords['y'] += $incr_y; $current_line = trim($coords[$current_coords['y']]); $actual_x = $current_coords['x'] % strlen($current_line); if ($current_line[$actual_x] === '#') $trees += 1; } return $trees; }