How do I make the first letter of a string uppercase?
The answer to your enquiry is the function called ucfirst() which doesn't mean you were the first person to see, but rather UpperCaseFirst.
Like this:
<?php
$unexpected = " how are you today?";
echo ucfirst($unexpected);
// how are you today?
?>
Note that you didn't get the expected result here, and that's because the first character is actually a space.
The lesson is, when using this function it is best to always pass the string through trim first to get rid of any leading space, so you always get the expected results:
<?php
$expected = " how are you today?";
echo ucfirst(trim($expected));
//How are you today?
?>
Comment on this Question and Answer >>>
ASK A QUESTION
More strings PHP Questions
How do I add commas easily to a string of numbers?How do I find the ASCII value of a string character?
How do I fetch the meta tags from a webpage using PHP?
How do I calculate the metaphone of a string?
How do I convert relevant characters in a string to HTML entities?
