Tuesday, July 28, 2009

How do I make every word in a string start with a capital letter using a regular expression in PHP?

I want to change: "my favourite car" into "My Favourite Car". Does anyone know how to do this in as little space as possible?

How do I make every word in a string start with a capital letter using a regular expression in PHP?
Just use ucwords();





$str = "my favourite car";





$str = ucwords($str); // My Favourite Car





Hope that helps,





Paul

love song lyrics

No comments:

Post a Comment