Saurdo Posted March 4, 2007 Share Posted March 4, 2007 I need a quick effective way to get the last character in a string. Maybe a character count of the string and then somehow getting the last character... Yeah, i don't know. It's probably really simple but i don't know my PHP functions well. Thanks! Quote Link to comment Share on other sites More sharing options...
doni49 Posted March 4, 2007 Share Posted March 4, 2007 Get specified characters from a string: http://us2.php.net/manual/en/function.substr.php Get length of string: http://us3.php.net/strlen Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 4, 2007 Share Posted March 4, 2007 http://ca.php.net/manual/en/function.substr.php - the very first example in the manual Quote Link to comment Share on other sites More sharing options...
Saurdo Posted March 4, 2007 Author Share Posted March 4, 2007 Yeah, substr is definitely what i needed. It even provides a negative count so you can get the last character. substr($string, -1, 1); Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.