Kichu
Kichu

Reputation: 3267

Ucfirst Returing Incorrect Result

In my code i have a string and i want to capitalize first letter of each word using php function.

This is my code:

$str = "144 beach st,daytona beach,FL,32114";
echo ucfirst($str);

It displays the same result:

144 beach st,daytona beach,FL,32114

So how can i capitalize the word?If there is any mistake in the code?

Upvotes: 0

Views: 88

Answers (1)

Sarfraz
Sarfraz

Reputation: 382726

You are looking for ucwords instead to capitialize first letter of each word.

$str = "144 beach st, daytona beach, FL, 32114";
echo ucwords($str);

Result:

144 Beach St, Daytona Beach, FL, 32114

Upvotes: 3

Related Questions