Take last 3 characters when string is big enough
<?php $str = "hello"; echo substr($str, -3); ?>
llo
Env: PHP 7.4.33 (Linux)
Take last 3 characters when string is smaller than 3 chars
<?php $str = "he"; echo substr($str, -3); ?>
he
Env: PHP 7.4.33 (Linux)