How to Get Last 2, 3, 4, 5, 7 Characters of a String in PHP?
Here, I will show you how to get last two characters of a string in php. We will use php get last 4 characters of string. you will learn php get last 3 characters of string. If you have a question about php get last 5 characters of string then I will give a simple example with a solution.
In this example, we will use substr() function to get last 2, 3, 4, 5 and 7 characters from string in php. so, let's see the following example code:
$string = "Welcome to ItSolutionstuff.com";
$last2Char = substr($string, -2);
$last3Char = substr($string, -3);
$last4Char = substr($string, -4);
$last5Char = substr($string, -5);
$last7Char = substr($string, -7);
I hope it can help you...
We are Recommending you
- How to Upgrade PHP Version from 8.1 to 8.2 in Ubuntu?
- PHP Get First 2, 3, 4, 5, 10 Character from String Example
- How to Get First and Last Character from String in PHP?
- How to Get Last Character from String in PHP?
- How to Get First Character from String in PHP?
- How to Remove Last Character from String in PHP?
- How to Remove First Character from String in PHP?
- PHP Remove First and Last Character from String Example
- How to Upgrade PHP Version from 7.2 to 7.3 in Ubuntu?
- How to Partially Hide Email Address in PHP?
- How to Remove Multiple Keys from PHP Array?
- PHP MySQL Login with Google Account Example
- PHP Ajax Form Validation Example Tutorial
- How to Find Day Name from Specific Date in PHP?