Advent of code 2019/8
Ajax Direct

Answer

Part 1 :
Part 2 :
// ==================================================
// > PART 1
// ==================================================
$layer = $input->chunk(25 * 6)->map(function ($layer) {
    return $layer->chars()->occurrences();
})->sort(fn ($a, $b) => $a[0] <=> $b[0])->first();

$solution_1 = $layer[1] * $layer[2];

// ==================================================
// > PART 2
// ==================================================
$solution_2 = $input->chunk(25 * 6)->reduce(function ($image, $layer) {
    foreach (str_split($layer) as $i=>$ch)
        if (empty($image[$i])) $image[$i] = match ($ch) {
            "0" => ".",
            "1" => "#",
            default => null
        };
    return $image;
}, set())->join("")->chunk(25)->join("<br>");