Вопрос

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?

Это было полезно?

Решение

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top