The best way in my opinion is what lazyjim said, though personally I would format it into the comma deliminated string using PHP, but if you want to limit your learning curve doing the formating with javascript would work as well.
Spend a few moments and go to php.net, best learning resource for PHP and its free. Specifically take a look at:
http://ca2.php.net/manual/en/function.fopen.php
fopen() is very easy to use and there are lot of examples there on the page, I use fopen() and its more complext partner fsockopen() probably more than anything else, well worth the time to check it out.
Cul