PHP solution to problem 19