php get last 3 character of string code example Example: take last four digits php $newstring = substr($dynamicstring, -7);