take the last two numbers from a php string code example Example: take last four digits php $newstring = substr($dynamicstring, -7);