Getting the first letter from a string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
8T8
Forum Newbie
Posts: 2
Joined: Fri Mar 23, 2007 2:07 pm

Getting the first letter from a string

Post by 8T8 »

Hi, I'm failry new to PHP. What is the best way to obtain the first letter in a string?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I've always tended to use $string[x]. x being the position in the string.
8T8
Forum Newbie
Posts: 2
Joined: Fri Mar 23, 2007 2:07 pm

Post by 8T8 »

Brilliant, Thanks! Its easy when you know how :D
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Be sure to test that the string is not empty, though. ;-)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

And that it is a string.
Post Reply