Part 2 :
function solve($input)
{
$i = 0;
$p1 = "";
$p2 = [];
while (count($p2) < 8) {
while (true) {
$i++;
if (str_starts_with($md5 = md5($input . $i), "00000")) {
$p1 .= $md5[5];
if ($md5[5] < 8) $p2[(int) $md5[5]] = $p2[(int) $md5[5]] ?? $md5[6];
break;
}
}
}
return [substr($p1, 0, 8), set($p2)->sortKeys()->values()->join("")];
}
[$solution_1, $solution_2] = solve($input);