title: CSV export script running out of memory
body: <p>I have a PHP script that exports a MySQL database to CSV format. The strange CSV format is a requirement for a 3rd party software application. It worked initially, but I am now running out of memory at line 743. My hosting service has a limit of 66MB. </p>
  
  <p>My complete code is listed here. <a href="http://pastebin.com/fi049z4n" rel="nofollow">http://pastebin.com/fi049z4n</a></p>
  
  <p>Are there alternatives to using <code>array_splice</code>? Can anyone please assist me in reducing memory usage. What functions can be changed? How do I free up memory?</p>