Question

I want to know how to capitalize in PHP

Was it helpful?

Solution

echo strtoupper('hello');

strtoupper will capitalize the whole string.

If you're only interested in capitalizing the first letter, you can use ucfirst:

echo ucfirst('hello!'); //Hello!

If you want to capitalize the first letter of each word in a string, use ucwords:

echo ucwords('hello world!'); //Hello World!

OTHER TIPS

The strtoupper() function is what you're looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top