Categories
PHP Tips & Tutorials

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

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?'

By Yang Yang

Hello, I'm Yang. I build online businesses that please people. Want to join in and post some useful articles on Kavoir.com? Shoot me a message.

One reply 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”

Comments are closed.