Improve php snippet