I just went through that same trip. You can't do this through PHP when PHP is running in apache and apache is running as nobody, its impossible.
The logical workaround is to use a CGI-wrapper, and call the PHP script through CGI. If you can't do this through linking strait to the CGI php page, there are a variety of ways to include the output of the CGI file in your other pages...This is not as limiting as you think...If you think about it, Its not that hard to include functions in regular pages that allow users to write to secure files. Write me if you have questions on that.