Jump to content

Splitting a Capitalised string


richardjh

Recommended Posts

Go through the string char by char, and use http://php.net/ctype-upper on the individual letters. Create a new string as you go along. If it's uppercase, add a space after it when you add the letter to your new string.

 

Also, you could store the original string as Wind-In-The-Willows and just use str_replace. If you're doing it for URLs or something, it's best to use a hyphen in place of your spaces.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.