I found an answer here: How to capitalize first letter of first word in a sentence? however, it doesn't work when the sentence starts with characters such as "
or «
.
The code found in the link above is:
$output = preg_replace('/([.!?])\s*(\w)/e', "strtoupper('\\1 \\2')", ucfirst(strtolower($input)));
Here's an example of the handling I need
$input => «the first article title»
$output => «The first article title»
$input => « the first article title »
$output => « The first article title »
$input => "être"
$output => "Étre"
The idea is to ignore any non alphabetic (not in [a-z, A-Z] + french characters) and apply to the first alphabetic one and the rest will remain the same as the input.