Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.