richardjh Posted December 20, 2007 Share Posted December 20, 2007 Is is possible to pull a string from a db table that looks like: WindInTheWillows and explode (or split) it so it so it appears on the webpage thus: Wind In The Willows ? thanks R Quote Link to comment https://forums.phpfreaks.com/topic/82577-splitting-a-capitalised-string/ Share on other sites More sharing options...
Jessica Posted December 20, 2007 Share Posted December 20, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/82577-splitting-a-capitalised-string/#findComment-419777 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.