PHP Script for CodeEval Challenge