get last 5 digit in php from particular number code example Example: take last four digits php $newstring = substr($dynamicstring, -7);