First example rewritten into PHP