Advent of code 2017/14
Ajax Direct

Answer 581ms

Part 1 : 8190 Part 2 : 1134
// Load hash function from day 10
include Aoc::path("solution.php", "2017", "10");

// Make the grid
for ($i = 0; $i < 128; $i++) {
    $hashes[] = implode("", array_map(function ($char) {
        return str_pad(base_convert(strtoupper($char), 16, 2), 4, "0", STR_PAD_LEFT);
    }, str_split(get_hash($input . "-" . $i))));
}

// ==================================================
// > PART 1
// ==================================================
$solution_1 = substr_count(implode("", $hashes), "1");

// ==================================================
// > PART 2
// ==================================================
$solution_2 = 0;
for ($x = 0; $x < 128; $x++) for ($y = 0; $y < 128; $y++) {
    if ($hashes[$y][$x] == "0") continue;

    $solution_2++;

    // Remove region with BFS
    $queue = [[$x, $y]];
    while (!empty($queue)) {
        $current = array_shift($queue);
        $hashes[$current[1]][$current[0]] = "0";
        foreach (neighbors($current, false, 0, 127, 0, 127) as $neighbor) {
            if ($hashes[$neighbor[1]][$neighbor[0]] == "1") {
                $queue[] = $neighbor;
            }
        }
    }
}