Jump to content

How do I capitalize the first letter after a pound sign?


MockY

Recommended Posts

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?

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! :P

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.