Use the CGI version of PHP and run if from a command line. PHP comes in two flavors, and Apache Module (which is the handiest), or as a CGI script. I usually install both because I like to use PHP for scripting, instead of PERL or BASH script (though BASH is powerful).
Then run it from a command prompt, with the path to your script. Or put the line
at the top of your script, chmod +x, and run it.
Need more help ? Contact me at http://www.bitesizeinc.net/