I need to get the last character of a string.
Say I have “testers” as input string and I want the result to be “s”. how can I do that in PHP?

12 s
12

substr("testers", -1); // returns "s"

Or, for multibytes strings :

substr("multibyte string…", -1); // returns "…"

Tags:

Leave a Reply

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