MockY Posted July 16, 2010 Share Posted July 16, 2010 When I capitalize the first letter in every word in a string, I simply use: $string = 'eVery firsT LEtter will BE caPITALIZED'; $string = ucwords(strtolower($string)); But what if $string contains the following? $string = '555 SOME STREET Suite #f'; How do I go about to capitalize the F efter the pound sign? Quote Link to comment https://forums.phpfreaks.com/topic/207988-how-do-i-capitalize-the-first-letter-after-a-pound-sign/ Share on other sites More sharing options...
Seaholme Posted July 16, 2010 Share Posted July 16, 2010 You should be able to use this: http://php.net/manual/en/function.preg-replace.php Example 4 looks much like what you want to do, if you just put your own variables in I'm not claiming this is the best way or that I'm especially experienced at this! I just reckon that would be a solution. Also, what you just used is the hash key/a sharp sign. £ is a pound sign! Quote Link to comment https://forums.phpfreaks.com/topic/207988-how-do-i-capitalize-the-first-letter-after-a-pound-sign/#findComment-1087275 Share on other sites More sharing options...
MockY Posted July 16, 2010 Author Share Posted July 16, 2010 Thanks for your reply, I will look into that. I live in the States and here we call # a pound sign Quote Link to comment https://forums.phpfreaks.com/topic/207988-how-do-i-capitalize-the-first-letter-after-a-pound-sign/#findComment-1087276 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.