•
•
•
•
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
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.
THe first letter is 0, as it is default as well.
Last edited : Sep 19th, 2007.
<?php function cap_letter($string,$letter=0) { $letters = str_split($string); $letters[$letter] = strtoupper($letters[$letter]); return implode($letters); } ?>
Comments (Newest First)
Shaffer | Newbie Poster | Sep 21st, 2007
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:
would return 'h'.
php Syntax (Toggle Plain Text)
$word = 'happy'; echo $word[0];
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
•
•
•
•
DaniWeb Marketplace (Sponsored Links)
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.