Get last character from string in PHP

Easy but not for all of us to get last character from string in PHP. It ‘s quite simple to figure out with a quick Google it. So if you found my article about this. Then you are in right place to solve this issuse with a simplest way.

php string

1. Get the last char of a string in PHP

If you want to get the only one character in a string, here is simplest function to do.

So simple?

And what if you want 2 characters? Let ‘s do this

 2. Remove the last character from string

Just a bonus if this article, if you want to remove the last character in a string. You can do this function

The output is a,b,c,d,e

Hope this article help you solve the problem with string.


Leave a Reply

Your email address will not be published. Required fields are marked *