#!/usr/bin/php = strlen($maze[$y]) || $maze[$y][$x + 1] == ' ') ? -1 : 1; $dir[1] = 0; } else { $dir[0] = 0; $dir[1] = ($y + 1 >= count($maze) || $maze[$y + 1][$x] == ' ') ? -1 : 1; } } $x += $dir[0]; $y += $dir[1]; $steps++; } echo $path . PHP_EOL; echo $steps . PHP_EOL;