Advent of code 2017/5
Ajax Direct

Answer

Part 1 :
Part 2 :
function solve($input, $part2 = false) {

    $inst = $input->numbers();
    $i = $j = 0;

    while ($i < $inst->count()) {
        $offset = $inst[$i];
        $inst[$i] += $part2 && $offset >= 3 ? -1 : 1;
        $i = $i + $offset;
        $j++;
    }

    return $j;
}

$solution_1 = solve($input);
$solution_2 = solve($input, 2);