last 5 digits/characters php code example Example: take last four digits php $newstring = substr($dynamicstring, -7);