To get the last 7 characters from a PHP string, we can use the
substr() function by passing the first argument as a string and second argument is
Here is an example
$string = "you are learningphp"; $lastseven = substr($string, -7); echo $lastseven;
Similarly, you can also get last n characters from a string by changing the second argument.
$string = "you are learningphp"; $lasttwo = substr($string, -2); echo $lasttwo;