Possible Duplicate:
Find last character in a string in PHP
How can I know if the last char of a $string is ‘,’ ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are a few options:
Or (slightly less readable):
Or (even less readable):
Or (even worse yet):
Or (wow this is bad):
The take away, is just use
substr($string, -1)and be done with it. But there are many other alternatives out there…