PHP solution to problem 20