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! Link to comment https://forums.phpfreaks.com/topic/41078-solved-get-last-character-in-string/ 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 Link to comment https://forums.phpfreaks.com/topic/41078-solved-get-last-character-in-string/#findComment-198925 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 Link to comment https://forums.phpfreaks.com/topic/41078-solved-get-last-character-in-string/#findComment-198926 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! Link to comment https://forums.phpfreaks.com/topic/41078-solved-get-last-character-in-string/#findComment-198927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.