PHP code for problem 9