To anyone wondering. I solved it by just randomly trying myself towards the solution.
SOLUTION:
$textbr = nl2br($text);
$output = preg_replace_callback(
'/([.!?\r?\n)])\s*(\w)/',
function ($matches) {
return strtoupper($matches[1] . ' ' . $matches[2]);
},
ucfirst(
strtolower($textbr)
)
);