how to get last 4 digits of number php code example Example: take last four digits php $newstring = substr($dynamicstring, -7);