Page 1 of 1

HELP! First letter of a variable

Posted: Wed Jun 30, 2004 7:33 pm
by rapaddict_dot_com
if I have a variable like $<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>="cheese"; how do I return just the first letter of it?

ie I want it to echo "c" in this case

Posted: Wed Jun 30, 2004 7:39 pm
by redmonkey

Code: Select all

$somevar = 'cheese';
echo $somevar{0};

Posted: Wed Jun 30, 2004 8:14 pm
by rapaddict_dot_com
life saver... thanks