For converting every first letter capital use the below code
Ex)
<?php
$data = "converting every first letter into capital letter.";
echo ucwords($data);
?>
Output:
Converting Every First Letter Into Capital Letter.
For converting the first letter capital in a sentence use the below code
Ex)
<?php
$data = "converting every first letter into capital letter.";
echo ucfirst($data);
?>
Output:
Converting every first letter into capital letter.
For converting the first letter capital in all sentence use the below code.
Ex)
<?php
$string = "this is a first message. this is a second message. this is a third message! hope this helps.";
$string = strtolower($string);
echo preg_replace('/(^|[\.!?]"?\s+)([a-z])/e', '"$1" . ucfirst("$2")', $string);
?>
Output:
This is a first message. This is a seconde message. This is a third message! Hope this helps.