Page 1 of 1

Getting the first letter from a string

Posted: Fri Mar 23, 2007 2:08 pm
by 8T8
Hi, I'm failry new to PHP. What is the best way to obtain the first letter in a string?

Posted: Fri Mar 23, 2007 2:11 pm
by feyd

Posted: Fri Mar 23, 2007 2:17 pm
by impulse()
I've always tended to use $string[x]. x being the position in the string.

Posted: Fri Mar 23, 2007 2:19 pm
by 8T8
Brilliant, Thanks! Its easy when you know how :D

Posted: Fri Mar 23, 2007 3:44 pm
by Ambush Commander
Be sure to test that the string is not empty, though. ;-)

Posted: Fri Mar 23, 2007 4:14 pm
by RobertGonzalez
And that it is a string.