how to get last 5 characters of a string in php code example Example: take last four digits php $newstring = substr($dynamicstring, -7);