PHP

PHP Get Last 4 Characters from a String Example1 min read

In this tutorial will help you for getting last 4 characters of a string in PHP language.

We used substr function for gettting four chars or any length.




You may also like: How to get the last character of a string in PHP (with multi byte chars)

Substr, Returns the portion of string specified by the offset and length parameters.

Here our example:

Output:

Leave a Comment