Advent of code 2015/1
Ajax Direct

Answer

Part 1 :
Part 2 :
// ==================================================
// > PART 1
// ==================================================
$count = $input->chars()->occurrences();
$solution_1 = $count["("] - $count[")"];

// ==================================================
// > PART 2
// ==================================================
$floor = 0;
foreach ($input->chars() as $i => $char) {
    $floor += $char == "(" ? 1 : -1;
    if ($floor == -1) {
        $solution_2 = $i + 1;
        break;
    }
}