Jump to content

[SOLVED] Changing String Capitalization


willpower

Recommended Posts

If this is a standalone string then a simple string replace on the letter l would do it but i'm guessing you have a series of strings so a function would be best.

 

function capitalizeName($name) {
$name = str_replace("'", " ' ", $name);
$name = ucwords($name);
$name = str_replace(" ' ", "'", $name);
return $name;
}


print capitalizeName("joe bloggs")."<br />";
print capitalizeName("mike o'leary");

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.