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