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