Uppercase first word in a string or sentence

I have just had a task which requires making the first word of a string uppercase. I have come up with quite an easy and simple solution and thought I would share it with you.

An example input string might look like “HELLO world. This is a test.” The required output is “Hello world. This is a test.”

Below is a function which will help you achieve this:

function uc_first_word($string) {
    $s = explode(' ', $string);
    $s[0] = ucfirst(strtolower($s[0]));
    $s = implode(' ', $s);
    return $s;

Now I know this function isn’t full proof, and assumes that the string you are passing actually contains words. If the first word was a roman numeral for example, this function would not work (ie VI would become Vi).

Usage of this function is quite easy:

$string = uc_first_word('HELLO world. This is a test.');

I hope that this might help someone searching for a similar solution.

Showing .htaccess files in Transmit FTP

I’ve been trying to work this one out for ages, but I’ve finally figured it out. I always like to be able to edit my .htaccess files, but seeing as they are hidden files, Transmit FTP would never show them. I always ended up going back to my PC and using CuteFTP Pro.

Turns out there is a simple option to show hidden files such as .htaccess in Transmit FTP. Simply select View -> Show Invisible Files.

So simple! I can’t believe I have missed this option all this time.

Mixed Windows XP and Windows Vista Network

I have had the pleasure of recieving a free copy of Windows Vista Business thanks to my university’s MSDN AA program. Last weekend I thought I would take the plunge and install the thing, alongside XP so I could still dual boot and use XP when needed.

Most things seem to be running quite smoothly in Vista, albeit slightly differently to XP. I have a few shared folders in XP which serve as place for family members to share and swap files over our network. With Windows XP users have never had any trouble connecting to my machine. This has all changed with Windows Vista however. When I first created the same shares in Windows Vista the other XP machines were unable to connect to the Vista shares. Each time it was asking for a user name and password. This was quite frustrating as when you install Vista it never asks you to setup any user accounts with passwords.

The final solution to the problem is to create a new user on the Vista machine. The user does not need to have administrative privileges but must have a password. Once this is done your XP machines should be able to connect to the Vista shares using the user name and password that you just created. This could become frustrating but thankfully you are able to save the user name and password in XP so each time you connect to the share in Vista from then on you no longer need to put in these details.

I hope you find this information useful and that it saves you a few headaches. I know I spent a few hours trying to find away around this problem. I take it the requirements for a password is part of Microsoft’s attempt to up security in Windows Vista.