Improved PHP function snippet.