Advent of code 2017/8
Ajax Direct

Answer

Part 1 :
Part 2 :
$cmd = (array) $input->lines->map(fn ($line) => explode(" ", $line->string));
$reg = array_fill_keys(array_unique(array_column($cmd, 0)), 0);
$max = 0;

foreach ($cmd as $c) {
    [$var, $op, $val, $_if, $a, $comp, $b] = $c;

    // Check condition
    $pass = match ($comp) {
        ">"  => $reg[$a] > $b,
        "<"  => $reg[$a] < $b,
        ">=" => $reg[$a] >= $b,
        "<=" => $reg[$a] <= $b,
        "==" => $reg[$a] == $b,
        "!=" => $reg[$a] != $b,
    };
    if (!$pass) continue;

    // Apply operation
    $reg[$var] = match ($op) {
        "inc" => $reg[$var] + $val,
        "dec" => $reg[$var] - $val,
    };

    $max = max($max, $reg[$var]);
}

// ==================================================
// > SOLUTIONS
// ==================================================
$solution_1 = max($reg);
$solution_2 = $max;