Advent of code 2017/11
Ajax Direct

Answer

Part 1 :
Part 2 :
// Use a normal grid, but with y offseted by -x
$dirs = [
    "n"  => [ 0, -1],
    "ne" => [ 1, -1],
    "se" => [ 1,  0],
    "s"  => [ 0,  1],
    "sw" => [-1,  1],
    "nw" => [-1,  0],
];

// Remove y offset to get true manhattan distance
function distance($pos) {
    [$x, $y] = [$pos[0], $pos[1]];
    if ($x < 0 && $y > 0 || $x > 0 && $y < 0) $y += $x;
    return abs($x) + abs($y);
}

// Move in each direction
$pos = [0, 0];
$max = 0;
foreach ($input->split(",") as $dir) {
    $pos[0] += $dirs[$dir->string][0];
    $pos[1] += $dirs[$dir->string][1];
    $max = max($max, distance($pos));
}

// Solutions
$solution_1 = distance($pos);
$solution_2 = $max;