About 5,000 phone boxes around the UK will be kept open if they fulfil certain criteria, says Ofcom.