It’s common that you need to reformat the texts in PHP and make them look a little more formal. For example, the first letter of all sentences should be uppercased, or with a title, the first letter of all words should also be made uppercase; in other situations, you may want all letters to be in uppercase.
Make all letters in a string lowercase
strtolower('ABc De!'); // returns 'abc de!'
Make all letters in a string uppercase
strtoupper('ABc De!'); // returns 'ABC DE!'
Make the first letter of every word uppercase
ucwords('world digital library'); // returns 'World Digital Library'
Make the first letter of a sentence uppercase
ucfirst('how are you?'); // returns 'How are you?'
1 thought on “PHP String Case: Uppercase all Letters or Lowercase all Letters in a String | Uppercase First Letter of a String | Uppercase First Letter of all Words in a String”
nice work ^_______________^ it’s very helpful
Comments are closed.