Uppercase the First Character of Each Word in a String Using PHP

  • Home /
  • Blog Posts /
  • Uppercase the first character of each word in a string using PHP

You can use “ucwords()” to uppercase the first character of each word in a string.

e.g.

$myVar = 'this is a test!';
$myVar = ucwords($myVar);
// This Is A Test!