How to make first char top in php?

I need to know how can I make a string like "hello"to "hello"using PHP? I just need the first character Upper

+3
source share
4 answers

use function ucwords(); This will do every word in a line, using ucfirst()will just make the first word.

echo ucwords('hello my name is jim');

// Hello My Name Is Jim

echo ucfirst('hello my name is jim');

// Hello my name is jim
+10
source

You need a function ucfirst.

Returns a string with the first character str, uppercase if this character is alphabetic.

It will not make other characters lowercase. To make sure that only the first letter is uppercase and all the rest are lowercase letters you can make:

ucfirst(strtolower($str))
+5
source
+2

: char

Usage: ucfirst ("first char of string"); // output First char of string

For: all first char words in a string

Usage: ucwords ("all first char words in a string") // prints All First char Word In String

+1
source

Source: https://habr.com/ru/post/1740429/


All Articles