User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 330,370 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,011 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Sep 17th, 2007
Views: 1,632
This function caps a specific letter of a string, and returns the updated string.
THe first letter is 0, as it is default as well.
Last edited : Sep 19th, 2007.
php Syntax
  1. <?php
  2. function cap_letter($string,$letter=0) {
  3. $letters = str_split($string);
  4. $letters[$letter] = strtoupper($letters[$letter]);
  5. return implode($letters);
  6. }
  7. ?>
Comments (Newest First)
Shaffer | Newbie Poster | Sep 21st, 2007
Hello,
Thanks for the feedback.
As for cscgal's comment, I want to say that I wanted to leave it with the least amount of code.

Thanks,
Shaffer.
cscgal | The Queen of DaniWeb | Sep 20th, 2007
Since a string is defined as an array of characters, you can actually just have line #4 without converting the string to and from an array. In other words:
  1. $word = 'happy';
  2. echo $word[0];
would return 'h'.
cscgal | The Queen of DaniWeb | Sep 19th, 2007
Title edited.
ShawnCplus | Code Monkey | Sep 18th, 2007
I think you mean capitalize. If you capitolize it you turn it into money. I wasn't aware PHP was the philosopher's stone of the 21st century
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 10:19 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC