Created solution to Problem 2 in PHP.