Updated PHP solution

Refactored current PHP solution to better match problem description